# Find the combination algorithm

Once a month, Jerry visits the restaurant that he owns. Being paranoid that someone will steal his fortune, on each visit he changes the combination to his personal safe, which is hidden in the back part of the managers' office.

On each update, Jerry uses the next number in a numerical pattern that he has been aware of for years, and is very confident that no one else will figure out. Each time, he jots the previous combination down on a sheet of paper, which is taped to the side of the safe, to remind him where he is in the sequence.

The safe has a simple, 10-button keypad, like below, and can be programmed to accept combinations from length 1 to length 15. After 3 failed attempts in a row to open the safe, a text will be sent to Jerry's phone. Therefore, guessing is not a great idea.

After some time, the restaurant managers find the small piece of paper taped to the safe, and figure out that the numbers are the previous combinations, and assume that a pattern or sequence of some kind is being followed. They are bored and would love to break into the safe, if only for the challenge. However, they have yet to be able to find the pattern.

Here is the list of previous combinations:

1
8
41
208
1041
5208
26041
130208
651041
3255208
16276041
81380208
406901041

What is the current combination?

Hint #1:

Eventually, Jerry's algorithm will produce combinations that are too long (>15 digits), but for now this works.

Hint #2

The sequence has nothing to do with letters or alphabets or changing bases, and nothing is encrypted.

• Does the pattern relates to the button positions in the picture you've shown? :D – Alex May 12 '15 at 20:04
• @Alex No. I just tried to find the most basic keypad. The number positions have no significance. – JLee May 12 '15 at 20:06
• Thanks @JLee, I figure I should ask before going deep into drawing arrows and stuff on the picture – Alex May 12 '15 at 20:08
• I kind of think that number-sequence and letter-sequence puzzles like this need their own site, because I think they really annoy most people, and get down-voted a lot, unless they incorporate other puzzle elements. – JLee May 12 '15 at 20:31
• It doesn't really annoys me (you've my upvote!), but it does make me scratch my head / open up excel and feels likes a dummy (esp when someone else got it within 2 minutes!) – Alex May 12 '15 at 20:36

To arrive at the new combination,

Jerry takes the previous combination, multiplies it by $5$, then adds either $1$ or $3$, depending on whether the previous combination was even or odd (respectively).

The next combination is

$406901041\times 5+3=2034505208$.

• I think you got it, just curious what do you use to solve this in such a short time? – Alex May 12 '15 at 20:17
• Damn. I thought this question would be too hard and I'd need to give more hints, and maybe even a bounty. This is correct, but the way you arrived there is not exactly what I had in mind. – JLee May 12 '15 at 20:19
• If you start at 1/1, 1/2, 1/3, ... 1/49152, and look only at the non-repeating digits of the decimals that repeat, for example, the 1 from 1/6, then you get a sequence. From that sequence, take the first instance of length 1, then the first instance of length 2, etc. Finally, remove any leading zeros. – JLee May 12 '15 at 20:27
• @Alex The combinations are getting larger, and I noticed each combination was about 5 times as big as the previous one. I computed how far each combination was from 5 times the previous one, and I noticed a pattern. – Julian Rosen May 12 '15 at 20:29
• @JLee Oh, interesting. It's not obvious to me that your description and my description will determine the same sequence (though it certainly looks like they will). – Julian Rosen May 12 '15 at 20:55

the 4 last digits should be 5208
last digit alternates between 1 and 8, so the current is 8
second to last digit alternates between 0 and 4, so the current is 0
third to last digit alternates between 0 and 2, so the current is 2
fourth to last digit is in the 1, 5, 6, 0 suite and start over, so the current is 5

I haven't found yet the end of the pattern, but that might help others

The question is too easy. All you have to do is look at the midway point such as 5208 and see that the next number is roughly 5 times that and then just play with the small difference to get it to match. I think this person deserves to have his safe cracked for picking such as bad algorithm.

• well, i agree with you! – JLee May 13 '15 at 1:19
• Ha ha, OP agrees with me and I still get downvoted. What a joke this site is. – David James May 15 '15 at 0:34
• I didn't down-vote you, but honestly, your answer didn't add any value, and just came off as negative. Better (for us and for you) would have been to just find another puzzle that you would enjoy. If you had read through the comments on the question and the accepted answer, you would have already known the story behind this puzzle, how I intended it to be one way, and then found it uninteresting when I saw it solved another way, which turned out to be too simple. I planned to delete it, but it had a few upvotes at the time, so I left it. – JLee May 15 '15 at 1:58
• Why didn't it add any value? What if I had answered first before anyone else, then would have it added value? Nobody in real life would ever be so careless to use such a simple code for a safe. Also, why would he post previous codes where people can see them? He could just keep a list in his wallet instead. The question is not "real world". – David James May 15 '15 at 2:50
• When you post an answer that is not an answer, then people routinely down-vote it. You are lucky that yours has only one down-vote. You had a comment, and instead of posting it as a comment, you posted it as an answer. It is perfectly OK to not like questions. Go ahead, down-vote it if you'd like. That is what life is all about. There will always be an infinite amount of stuff that you don't like or approve of or would do differently. The solution: acknowledge it, and move on to something that interests you. The quicker you can make this transition, the happier you will be. – JLee May 15 '15 at 14:27