login
First differences of digit sums of squares, cf. A004159.
5

%I #18 Mar 15 2023 17:04:56

%S 1,3,5,-2,0,2,4,-3,-1,-8,3,5,7,0,-7,4,6,-10,1,-6,5,7,0,2,-5,6,-1,1,-6,

%T -4,7,-9,11,-5,-3,8,1,-6,-4,-2,9,2,4,-3,-10,1,3,-4,-2,0,2,4,6,-1,-8,3,

%U 5,-2,0,-7,4,6,8,-8,-6,5,7,-9,2,-5,-3,8,1,3,-4

%N First differences of digit sums of squares, cf. A004159.

%H Reinhard Zumkeller, <a href="/A240752/b240752.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A004159(n) - A004159(n-1).

%F a(n) = A007953(A000290(n)) - A007953(A000290(n-1)).

%F a(A202089(n)+1) = 0; a(A239878(n)+1) = 1; a(A240754(n)+1) = -1.

%t Differences[Total[IntegerDigits[#]]&/@(Range[0,80]^2)] (* _Harvey P. Dale_, Mar 10 2019 *)

%o (Haskell)

%o a240752 n = a240752_list !! (n-1)

%o a240752_list = zipWith (-) (tail a004159_list) a004159_list

%o (PARI) a(n) = sumdigits(n^2) - sumdigits((n-1)^2); \\ _Michel Marcus_, Jan 24 2022

%o (Python)

%o def A240752(n): return sum(map(int,str(m:=n**2)))-sum(map(int,str(m-(n<<1)+1))) # _Chai Wah Wu_, Mar 15 2023

%Y Cf. A004159, A000290, A007953.

%Y Cf. A202089, A239878, A240754.

%K sign,base

%O 1,2

%A _Reinhard Zumkeller_, Apr 12 2014

%E Formulas adapted to offset by _Michel Marcus_, Jan 25 2022