cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A132295 Sum of the nonsquare numbers not larger than n.

Original entry on oeis.org

0, 2, 5, 5, 10, 16, 23, 31, 31, 41, 52, 64, 77, 91, 106, 106, 123, 141, 160, 180, 201, 223, 246, 270, 270, 296, 323, 351, 380, 410, 441, 473, 506, 540, 575, 575, 612, 650, 689, 729, 770, 812, 855, 899, 944, 990, 1037, 1085, 1085, 1135, 1186, 1238, 1291, 1345
Offset: 1

Views

Author

Cino Hilliard, Nov 07 2007

Keywords

Examples

			Let n=5. The sum of the nonsquare numbers <= 5 is 2+3+5 = 10, the 5th entry in the sequence.
		

Crossrefs

Programs

  • Mathematica
    Table[Total[Select[Range[n],!IntegerQ[Sqrt[#]]&]],{n,54}] (* James C. McMahon, Mar 04 2025 *)
  • 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
    def A132295(n): return n*(n+1)//2-A000330(isqrt(n)) # Jason Yuen, Jan 30 2024

Formula

Let r = floor(sqrt(n)). Then a(n) = n(n+1)/2 - r(r+1)(2r+1)/6.

Extensions

Definition corrected by R. J. Mathar, Sep 10 2016