OFFSET
1,1
COMMENTS
Start with any positive integer K. At each step, add the first two digits and append the sum to the end, then remove the first digit to obtain the new state. Iterate until K reappears, and then a(K) is the number of steps until K reappears. (Definition corrected by Allan Wechsler.)
If K never reappears, a(K) = 0.
As we need at least two digits to start the procedure, we decide that a(1) to a(9) are to be written as 01, 02, 03, 04, 05, 06, 07, 08 and 09.
Conjecture: a(K) = 0 if K contains any of the substrings '00', '20', '30', '40', '50', '60', '70', '80', or '90', or the substrings '132', '232', '356', '358', '532', '534', '632', '634', '635', '656', '732', '734', '832', '834', '835', '932', '934', '935', or '958'. - Hans Havermann, Aug 21 2021
LINKS
Eric Angelini et al., When-is-my-pattern-coming-back, Math Fun mailing list, August 2021.
Hans Havermann, Number of steps for 10 to 1000.
EXAMPLE
09 is successively transformed as follows:
09
.99
..918
...1810
....8109
and 09 reappears after 4 steps, so a(9) = 4.
10 will be successively transformed as follows:
10
.01
..11
...12
....23
.....35
......58
.......813
........139
.........394
..........9412
...........41213
............12135 etc.
The full string (without erasures) after 35 steps is:
10112358139412135334886712161413833775541111610, and "10" has reappeared, ending the procedure. The next digit is 1, so starting at "01" (line 2) would also take 35 steps for "01" to reappear. Hence a(1) = 35.
a(735) = 3213292, where the full string contains 4143987 digits.
MATHEMATICA
g[n_]:=Join[Rest@n, IntegerDigits@Total[n[[;; 2]]]]; Table[k=If[Mod[k, 10]==0, If[Mod[k, 100]==10, k, 0], k];
If[k==0, 0, d=g@If[k<10, b=""<>{"0", ToString@k}; Join[{0}, {k}], b=ToString@k; IntegerDigits@k];
Length@NestWhileList[g@#&, d, !StringContainsQ[ToString@FromDigits@#,
b]&]], {k, 131}] (* Giorgos Kalogeropoulos, Aug 19 2021 *)
PROG
(Python)
def delta(s): return str(int(s[0]) + int(s[1]))
def a(n):
if n%10 == 0 and n%100 != 10: return 0
s = "0"*(n < 10) + str(n)
i, target, nexts = 1, s[:], delta(s[:2])
s = s[1:] + nexts
while target not in s:
nexts = delta(s[:2])
s = s[1:] + nexts
i += 1
return i
print([a(n) for n in range(1, 132)]) # Michael S. Branicky, Aug 19 2021
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Eric Angelini and Hans Havermann, Aug 19 2021
EXTENSIONS
Edited by N. J. A. Sloane, Aug 31 2021
STATUS
approved