OFFSET
1,2
LINKS
Jason Yuen, Table of n, a(n) for n = 1..10000
FORMULA
Let r = floor(sqrt(n)). Then a(n) = n(n+1)/2 - r(r+1)(2r+1)/6.
EXAMPLE
Let n=5. The sum of the nonsquare numbers <= 5 is 2+3+5 = 10, the 5th entry in the sequence.
PROG
(PARI) sumNsq(n)= { for(x=1, n, r=floor(sqrt(x)); sq=r*(r+1)*(2*r+1)/6; sn=x*(x+1)/2; print1(sn-sq", ")) }
(Python)
from math import isqrt
def A000330(n): return n*(n+1)*(2*n+1)//6
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Cino Hilliard, Nov 07 2007
EXTENSIONS
Definition corrected by R. J. Mathar, Sep 10 2016
STATUS
approved