Skip to main content
3 of 3
explanation
Sparr
  • 6.1k
  • 27
  • 37

Mathematica, 35 characters

f[n_]:=Sum[SquaresR[2,k],{k,0,n^2}] 

Lifted from https://oeis.org/A000328

https://reference.wolfram.com/language/ref/SquaresR.html

SquaresR[2,k] is the number of ways to represent k as the sum of two squares, which is the same as the number of lattice points on a circle of radius k^2. Sum from k=0 to k=n^2 to find all the points on or inside a circle of radius n.

Sparr
  • 6.1k
  • 27
  • 37