OFFSET
0,20
LINKS
Chai Wah Wu, Table of n, a(n) for n = 0..10000
Antonios Meimaris, On the additive persistence of a number in base p, Preprint, 2015.
N. J. A. Sloane, The persistence of a number, J. Recreational Math., 6 (1973), 97-98.
Eric Weisstein's World of Mathematics, Additive Persistence
MAPLE
read("transforms") ;
A031286 := proc(n)
local a, nper;
nper := n ;
a := 0 ;
while nper > 9 do
nper := digsum(nper) ;
a := a+1 ;
end do:
a ;
end proc:
seq(A031286(n), n=0..80) ; # R. J. Mathar, Jan 02 2018
MATHEMATICA
lst = {}; Do[s = 0; While[n > 9, s++; n = Plus @@ IntegerDigits[n]]; AppendTo[lst, s], {n, 0, 98}]; lst (* Arkadiusz Wesolowski, Oct 17 2012 *)
PROG
(PARI) dsum(n)=my(s); while(n, s+=n%10; n\=10); s
a(n)=my(s); while(n>9, s++; n=dsum(n)); s \\ Charles R Greathouse IV, Sep 13 2012
(Python)
def A031286(n):
ap = 0
while n > 9:
n = sum(int(d) for d in str(n))
ap += 1
return ap
# Chai Wah Wu, Aug 23 2014
CROSSREFS
KEYWORD
nonn,base
AUTHOR
EXTENSIONS
Corrected by Reinhard Zumkeller, Feb 05 2009
STATUS
approved