OFFSET
1,1
COMMENTS
The procedure: Start with decimal number p. From left to right, determine the absolute differences between p's adjacent digits (ending with the last digit of p minus the first digit). Concatenate these differences to create decimal number q. If q > p, compute p + q. If q < p, compute p - q. Either way, this is our new p. Repeat.
13094 is the smallest number not known to enter a cycle. Phil Carmody has calculated more than 150*10^6 iterations, resulting in a number with more than 210000 digits.
Under the procedure some numbers (199, 10853, 10886, ..) require many iterations before entering a cycle. Cycles may be quite lengthy: 204099163 is the smallest member of a size-868 cycle.
LINKS
Hans Havermann, Table of n, a(n) for n = 1..10000
Eric Angelini, Add or subtract the result. Iterate.
E. Angelini, Add or subtract the result. Iterate. [Cached copy, with permission]
Hans Havermann, 13094
EXAMPLE
p = 13094; |1-3|=2, |3-0|=3, |0-9|=9, |9-4|=5, |4-1|=3; q = 23953; q > p so new p is p + q = 37047.
p = 37047; |3-7|=4, |7-0|=7, |0-4|=4, |4-7|=3, |7-3|=4; q = 47434; q > p so new p is p + q = 84481.
p = 84481; |8-4|=4, |4-4|=0, |4-8|=4, |8-1|=7, |1-8|=7; q = 40477; q < p so new p is p - q = 44004.
MATHEMATICA
f[p_] := (d=IntegerDigits[p]; r=RotateLeft[d]; q=FromDigits[Abs[d-r]]; If[q>p, p+q, p-q])
NestList[f, 13094, 100000]
CROSSREFS
KEYWORD
nonn,base,nice
AUTHOR
Hans Havermann, Jan 06 2014
STATUS
approved