A084228 a(1)=1, a(2)=2; thereafter a(n) = sum of digits of (a(1)+a(2)+a(3)+...+a(n-1)).
1, 2, 3, 6, 3, 6, 3, 6, 3, 6, 12, 6, 12, 15, 12, 15, 3, 6, 3, 6, 12, 6, 12, 15, 12, 15, 3, 6, 3, 6, 12, 6, 12, 15, 12, 15, 12, 6, 12, 6, 12, 15, 12, 15, 12, 15, 12, 6, 12, 15, 12, 15, 12, 15, 12, 15, 12, 15, 12, 15, 21, 15, 12, 15, 12, 15, 21, 24, 12, 15, 12, 15, 21, 24, 12, 15, 21, 15
Offset: 1
Links
Programs
-
Haskell
a084228 n = a084228_list !! (n-1) a084228_list = 1 : 2 : f 3 where f x = y : f (x + y) where y = a007953 x -- Reinhard Zumkeller, Nov 13 2014
-
Mathematica
a[1] = 1; a[2] = 2; a[n_] := a[n] = Sum[ Total@ IntegerDigits@ a@ i, {i, n - 1}]; Array[ Total@ IntegerDigits@ a@# &, 78] (* Robert G. Wilson v, Jun 27 2014 *) nxt[{t_,a_}]:=Module[{c=Total[IntegerDigits[t]]},{t+c,c}]; Join[{1},NestList[nxt,{3,2},80][[;;,2]]] (* Harvey P. Dale, Jul 13 2023 *)
-
PARI
sumdig(n)=sum(k=0,ceil(log(n)/log(10)),floor(n/10^k)%10) an=vector(10000); a(n)=if(n<0,0,an[n]) an[1]=1; an[2]=2; for(n=3,300,an[n]=sumdig(sum(k=1,n-1,a(k))))
Comments