login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) = Sum_{k=1..n} k^c(k), where c(n) is the characteristic function of squares.
1

%I #7 May 24 2021 23:31:04

%S 1,2,3,7,8,9,10,11,20,21,22,23,24,25,26,42,43,44,45,46,47,48,49,50,75,

%T 76,77,78,79,80,81,82,83,84,85,121,122,123,124,125,126,127,128,129,

%U 130,131,132,133,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,260

%N a(n) = Sum_{k=1..n} k^c(k), where c(n) is the characteristic function of squares.

%C For 1 <= k <= n, take a running total: add k if k is a perfect square, otherwise add 1. For example, a(12) = 1+1+1+4+1+1+1+1+9+1+1+1 = 23.

%F a(n) = n+m*(m-1)*(2*m+5)/6 where m = floor(sqrt(n)). - _Chai Wah Wu_, May 24 2021

%t Table[Sum[i^(Floor[Sqrt[i]] - Floor[Sqrt[i - 1]]), {i, n}], {n, 80}]

%o (Python 3.8+)

%o from math import isqrt

%o def A344624(n):

%o m = isqrt(n)

%o return n + m*(m-1)*(2*m+5)//6 # _Chai Wah Wu_, May 24 2021

%Y Cf. A010052.

%K nonn

%O 1,2

%A _Wesley Ivan Hurt_, May 24 2021