OFFSET
1,2
COMMENTS
A self-generating sequence.
Invented by Eric Angelini. Might also be called a lizard sequence (une suite du lézard) because it grows back from its tail.
REFERENCES
J.-P. Delahaye, La suite du lézard et autres inventions, Pour la Science, No. 353, 2007.
MAPLE
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
MATHEMATICA
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];
Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Aug 02 2022, after M. F. Hasler *)
PROG
(PARI) a(n, m=10)=while(n>=m, if(n%m, n-=n\m, n\=m)); n \\ M. F. Hasler, Mar 07 2015
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
N. J. A. Sloane, Feb 09 2007
EXTENSIONS
More terms from R. J. Mathar, Oct 02 2007
Definition rephrased by M. F. Hasler, Mar 09 2015
STATUS
approved