This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.
%I A117831 #12 May 07 2020 15:35:38 %S A117831 1,1,40,7,0,0,39,6,0,0,38,5,0,18,37,3,0,43,10,0,4,42,9,4,4,41,7,0,47, %T A117831 40,0,8,46,13,0,8,45,11,0,7,44,0,12,50,17,3,12,49,15,1,11,48,1,16,36, %U A117831 3,0,16,35,1,0,41,8,2,2,40,7,2,2,39,5,0,45,12,0,6,44,11,0,6,43,9,0,49,42,0,10 %N A117831 Let S_n be the infinite sequence formed by starting with n and repeatedly reversing the digits and adding 4 to get the next term. Sequence gives number of steps for S_n to reach a cycle, or -1 if no cycle is ever reached. %C A117831 It is conjectured that S_n always reaches a cycle. %C A117831 There are 22 different cycles of length 90 with 4-digit components. I guess that at most half of the numbers between 1000 and 10000 lead to the cycle of length 54 shown in A117830. - _Klaus Brockhaus_, May 05 2006 %H A117831 Robert Israel, <a href="/A117831/b117831.txt">Table of n, a(n) for n = 1..10000</a> %H A117831 N. J. A. Sloane and others, <a href="/wiki/Sequences_of_RADD_type">Sequences of RADD type</a>, OEIS wiki. %p A117831 V:= Vector(10^5,-1): %p A117831 f:= proc(n) %p A117831 local L, H, S, i, j,found,x,y; %p A117831 global V; %p A117831 S:= {n}: H:= n; x:= n; %p A117831 for i from 1 to 10^5 do %p A117831 if V[x] > -1 then %p A117831 for j from 1 to i-1 do V[H[j]]:= i-j+V[x] od; %p A117831 return V[n]; %p A117831 fi; %p A117831 L:= convert(x,base,10); %p A117831 x:= add(L[-j]*10^(j-1),j=1..nops(L)) + 4; %p A117831 if member(x, S) then %p A117831 found:= false; y:= 0; %p A117831 V[x]:= 0; %p A117831 for j from i by -1 to 1 do %p A117831 if H[j] = x then found:= true %p A117831 elif not found then V[H[j]]:= 0 %p A117831 else y:= y+1; V[H[j]]:= y; %p A117831 fi %p A117831 od; %p A117831 return V[n] %p A117831 fi; %p A117831 H:= H, x; %p A117831 S:= S union {x}; %p A117831 od; %p A117831 end proc: %p A117831 map(f, [$1..200]); # _Robert Israel_, May 07 2020 %Y A117831 S_1 is given in A117828, S_3 in A117829, S_1015 in A117807. %Y A117831 Records are in A118473, A118474. %Y A117831 Full list of sequences on this topic (1): A117230, A117521, A117800, A117816, A117817, A117827, A117828, A117829, A117830, A117831 (this sequence) %Y A117831 Full list of sequences on this topic (2): A117837, A117841, A118473, A118474, A118510, A118511, A118512, A118513, A118514, A118515, A118516 %Y A117831 Full list of sequences on this topic (3): A118517-A118533, A118535 %K A117831 nonn,base %O A117831 1,3 %A A117831 _N. J. A. Sloane_, following discussions with Luc Stevens, May 03 2006 %E A117831 Corrected and extended by _Klaus Brockhaus_, May 05 2006 %E A117831 Confirmed by _N. J. A. Sloane_, May 05 2006