FaceBook Hacker Cup 2011: Output the number of ways to write X as the sum of two squares