%I #38 Dec 12 2023 11:28:58
%S 0,-1,2684,505,22,-1,109,5000005,-1,-1,-1,-1,101,-1,-1,50005,-1,-1,-1,
%T -1,20000,-1,-1,-1,100012,-1,-1,-1,4999449,-1,-1,
%U 5000000000000000000000000000005,-1
%N Consider a decimal number of k >= 2 digits m = d_(k)*10^(k-1) + d_(k-1)*10^(k-2) + ... + d_(2)*10 + d_(1). a(n) is the least number m such that the n-th iteration of the transform T(m) -> (d_(k) + d_(k-1) mod 10)*10^(k-1) + (d_(k-1) + d_(k-2) mod 10)*10^(k-2) + ... + (d_(2) + d_(1) mod 10)*10 + (d_(1) + d(k) mod 10) returns m, or -1 if no such number exists.
%C a(0)=0, meaning the smallest m such that if the transformation is never applied (or is applied zero times) what you get is m itself.
%C For any pair of consecutive digits 'L' and 'R', the digit on the left is replaced by (L+R) mod 10. The least significant digit is replaced by the sum mod 10 of itself and the most significant digit. If we change the rule (digit on the right replaced by (L+R) mod 10 and most significant digit replaced by sum mod 10 of itself and the least significant digit) we get a similar sequence where only a(2)=2486 is different.
%C If through the transform leading zeros are created they are kept for the next calculation (see example for n = 3, 6, 12 and 15).
%C a(n) is the smallest k whose first return to itself occurs on the n-th iteration. For instance, if the iterations were continued, 22 would return to itself on iterations 4, 8, 12, etc., but 101 (not 22) is a(12).
%C In the file "Other possible entries" are listed some possible candidates. Other intermediate steps and numbers could be missing and the listed numbers may not be the minima.
%H Paolo P. Lava, <a href="/A243993/a243993_2.txt">Other possible entries</a>
%e n=2: 2684 -> 8426 -> 2684.
%e n=3: 505 -> 550 -> 055 -> 505.
%e n=4: 22 -> 44 -> 88 -> 66 -> 22.
%e n=6: 109 -> 190 -> 091 -> 901 -> 910 -> 019 -> 109.
%e n=12: 101 -> 112 -> 233 -> 565 -> 110 -> 211 -> 323 -> 556 -> 011 -> 121 -> 332 -> 655 -> 101.
%e n=15: 50005 -> 50050 -> 50555 -> 55000 -> 05005 -> 55055 -> 05500 -> 50500 -> 55505 -> 00550 -> 05050 -> 55550 -> 00055 -> 00505 -> 05555 -> 50005.
%e Etc.
%p # Maple program lists {step,least number} when found (not in order).
%p P:=proc(q) local a,b,c,d,j,k,n,ok,v;
%p v:=array(1..5000); for k from 1 to 5000 do v[k]:=0; od;
%p for n from 10 to q do a:=[]; b:=n; while b>0 do a:=[b mod 10,op(a)];
%p b:=trunc(b/10); od; b:=0; c:=a; ok:=0;
%p for k from 1 to 10^nops(a) do b:=b+1; d:=(c[nops(c)]+c[1]) mod 10;
%p for j from 1 to nops(c)-1 do c[j]:=(c[j]+c[j+1]) mod 10; od; c[nops(c)]:=d;
%p if a=c then ok:=1; break; fi; od; if ok=1 then if v[b]=0 then v[b]:=n;
%p print(n); fi; fi; od; end: P(10^10);
%t g[n_] := Block[{e = 1 + Floor@ Log10@ n, id = Reverse@ IntegerDigits@ n}, PrependTo[id, id[[-1]]]; Sum[10^(k - 1)*Mod[id[[k]] + id[[k + 1]], 10], {k, e}]]; f[n_] := Block[{lst = NestWhileList[ g@# &, n, UnsameQ || ## != 0, All]}, If[ lst[[-1]] == n, Length@ lst - 1, 0]];
%Y Cf. A243994.
%K sign,base,more
%O 0,3
%A _Paolo P. Lava_ and _Robert G. Wilson v_, Jun 17 2014