# Find the algorithm behind this repeating number sequence

During a garage sale I saw a strange old electronic device (not really, it's just flavor story). It had a battery slot, a button and a row of seven-segment displays - though from all except the two last digits the magic smoke had clearly escaped. Curious, I bought it for a dollar, took it home and put in a battery. Right away a single-digit number showed on the display (not a 7). I pressed the button, and the number changed. Trying it a few more times, I noticed a pattern to the numbers: it always went

97, 65, 85,    67, 15, 35,
37, 65, 85,    07, 15, 35,
77, 65, 85,    47, 15, 35,
17, 65, 85,    87, 15, 35,
57, 65, 85,    27, 15, 35.


After a while I got bored, so I threw the device away. However, it has been nagging at me what rule might be underlying the pattern of this number sequence. Maybe you know?

• The pattern among each column seems somewhat straightforward, but the transition from 85 to 67 is boggling. Following my theory, I would have expected it to cycle back to 97. – Bulldogg6404 Apr 11 '15 at 14:17
• I'm guessing it's powers of some number, personally. – Joe Z. Apr 11 '15 at 20:00
• Given the many old and strange calculating devices found on this site, maybe there really is a garage sale. – Aravind Apr 12 '15 at 5:57
• All the specific numbers shown follow the rule $a_n=(a_{n-3}\cdot 11)\;\%\;100$. That doesn't explain the single-digit starting number, though. – Sebastian Reichelt Apr 15 '15 at 20:39
• @quimnuss I believe there are a certain amount of seven-segment displays, yet only the last two work. The first $N$ places of the numbers are still included in the computation, but it only shows the last 2 digits. – mdc32 Apr 19 '15 at 14:22

In the hope of being told what the real answer is supposed to be, here is a strange rule that produces the correct numbers (using "min", since you mentioned it):

$a_0 = 9$

$a_{n+1} = \min((a_n \cdot 100)\,\%\,1000000 + (\lfloor a_n / 10000 \rfloor \cdot 11)\,\%\,100, 976585)$

$a_5$ is the first item that belongs to the repeating sequence, but it is not the beginning of that sequence. The sequence starts over for the first time at $a_{33}$.

• While not the one I intended, it does fit the pattern offered. I'll wait if anyone comes up with something better, though. – user66554 Apr 22 '15 at 6:38

So, this probably doesn't have much of anything to do with anything, but...

Treat this not as six columns but as three:

97, 65, 85,
37, 65, 85,
77, 65, 85,
17, 65, 85,
57, 65, 85,


67, 15, 35,
07, 15, 35,
47, 15, 35,
87, 15, 35,
27, 15, 35.


The first column loops -60,+40 while the second and third columns are identical down. 57 would go down to -3. Since there are only seven segment displays, there is no easy way to show a negative with two places.

I can't quite resolve a good reason for the two extra columns to drop down. Together they lose 100, assuming this is a base 10 system. But why assume that? Perhaps the single digit number that flashed was the base for this counter...

Take just the first columns from both blocks. To find the next single digit, add 7 to the current digit and consider only the the digit corresponding to the unit. The pattern starts with the digit 9 on the 1st line on the 1st block: • 9 + 7 = 16 => 6 on the 2nd block • 6 + 7 = 13 => 3 on the 1st block • 3 + 7 = 10 => 0 on the 2nd block • etc...

Simple algorithm, just needs formatting to pad number with a zero

Cstart=97

C=Cstart

I=1

While I==1 or C <> Cstart

Print (C)

Print (“,65,85,     “)

C=C-30

If C<0

C=100-C

Print (c)

Print (“,15,35\n”)

C=C-30

If C<100

C=C-30

I++