login
a(n) = a(n-1) + sum of digits of n^2.
7

%I #24 Jul 12 2023 13:00:53

%S 0,1,5,14,21,28,37,50,60,69,70,74,83,99,115,124,137,156,165,175,179,

%T 188,204,220,238,251,270,288,307,320,329,345,352,370,383,393,411,430,

%U 443,452,459,475,493,515,534,543,553,566,575,582,589,598,611,630,648,658

%N a(n) = a(n-1) + sum of digits of n^2.

%D N. Agronomof, Question 4419, L'Intermédiaire des Math. 21 (1914) 147.

%H Reinhard Zumkeller, <a href="/A071317/b071317.txt">Table of n, a(n) for n = 0..10000</a>

%t s=0; Do[s=s+Apply[Plus, IntegerDigits[n^2]]; Print[s], {n, 1, 128}]

%t nxt[{n_,a_}]:={n+1,a+Total[IntegerDigits[(n+1)^2]]}; NestList[nxt,{0,0},60][[All,2]] (* _Harvey P. Dale_, Mar 09 2017 *)

%t FoldList[#1 + Total@ IntegerDigits[#2^2] &, 0, Range@ 55] (* _Michael De Vlieger_, Mar 25 2017 *)

%t Accumulate[Plus @@@ IntegerDigits[Range[0, 50]^2]] (* _Giovanni Resta_, Mar 25 2017 *)

%o (Haskell)

%o a071317 n = a071317_list !! n

%o a071317_list = scanl1 (+) a004159_list

%o -- _Reinhard Zumkeller_, Apr 12 2014

%o (Python)

%o from itertools import count, islice, accumulate

%o def A071317_gen(): # generator of terms

%o return accumulate(map(lambda n:sum(map(int,str(n**2))),count(0)))

%o A071317_list = list(islice(A071317_gen(),20)) # _Chai Wah Wu_, Mar 15 2023

%Y Cf. A007953, A037123, A000788, A051351.

%Y Partial sums of A004159.

%K easy,nonn,base

%O 0,3

%A _Labos Elemer_, May 27 2002

%E a(0) = 0 prepended by _Reinhard Zumkeller_, Apr 12 2014