Who would suspect, for example, that on the average, the number of ways of expressing a positive integer

**n** as a sum of two integral squares,

i.e.

**n=x^2 + y^2 ** is

**Q** ?

Evaluate the expected value
**Q**.

Surprised?

Yes, this one did surprise me a little.

I started using circles to try to do the calculation, thinking that it might be the average number of lattice points in a circle of radius sqrt(n).

But I could not convince myself that this was right, so I calculated the first several, which were:

n number of ways

-- -------------------

1 4 (since zeroes and negatives are allowed)

2 4

3 0

4 4

5 8

6 0

7 0

8 4

9 4

10 8

and then found the sequence in oeis,

A004018

The first 10,000 values are listed

here

And the cumulative average of the first 483 was calculated in Excel. The last 10 terms were all somewhere between 3.095 and 3.145.

I suspect that the average is converging to Pi. Not a total surprise, but a very satisfying result. It turns out that my first thought was right, and now I see why.

Nice problem, Ady!

*Edited on ***September 5, 2015, 1:04 pm**