
I'm trying to do a calculation for Gauss' circle problem, which counts the
integer lattice points with distance to the origin <= r. It's sequence
A000328 on the AT&T integer sequence database. I can't figure out a way to
do it quickly in Haskell for r around 10^9.
Here's my attempt, which takes about 75s for r=10^8.
circ2 r = (1+4*r) + 4 * (circ2' (rs+1) r 1 0)
where
rs = r^2
-- circ2' :: Int64 -> Int64 -> Int64 -> Int64 -> Int64
circ2' rad x y sum
| x