%I #25 Aug 02 2022 09:18:45
%S 1,2,3,4,5,6,7,8,9,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,3,2,1,3,2,
%T 1,3,2,1,3,4,2,1,3,4,2,1,3,4,2,5,1,3,4,2,5,1,3,4,2,6,5,1,3,4,2,6,5,1,
%U 3,7,4,2,6,5,1,3,7,4,2,8,6,5,1,3,7,4,2,8,6,9,5,1,3,7,4,2,8,6,9,1,5,1,3,7,4
%N a(n) = n for n < 10, a(10*n) = a(n), and if the terms a(10), a(20), a(30), ... are deleted, one gets back the original sequence.
%C A self-generating sequence.
%C Invented by Eric Angelini. Might also be called a lizard sequence (une suite du lézard) because it grows back from its tail.
%D J.-P. Delahaye, La suite du lézard et autres inventions, Pour la Science, No. 353, 2007.
%p A126616 := proc(n) option remember ; if n < 10 then n ; elif n mod 10 = 0 then A126616(n/10) ; else A126616( n-floor(n/10) ) ; fi ; end: seq(A126616(n),n=1..120) ; # _R. J. Mathar_, Oct 02 2007
%t a[n_] := Module[{m = 10, k = n, q}, While[k >= m, q = Quotient[k, m]; If[Mod[k, m] != 0, k -= q, k = q]]; k];
%t Table[a[n], {n, 1, 105}] (* _Jean-François Alcover_, Aug 02 2022, after _M. F. Hasler_ *)
%o (PARI) a(n,m=10)=while(n>=m,if(n%m,n-=n\m,n\=m));n \\ _M. F. Hasler_, Mar 07 2015
%Y Cf. A117943, A178931, A255824 - A255829.
%K nonn,easy
%O 1,2
%A _N. J. A. Sloane_, Feb 09 2007
%E More terms from _R. J. Mathar_, Oct 02 2007
%E Definition rephrased by _M. F. Hasler_, Mar 09 2015
|