I am trying to find all of the answers to $r_2(n^2) = 420$, where $N < 10^{11}$. It is for finding lattice points on a circle with points $(0,0), (N,0), (0,N)$, and $(N,N)$. I am (pretty) sure that all of the following answers work:

359125, 469625, 612625, 718250, 781625, 866125, 933725, 939250, 1047625, 1119625, 1225250, 1288625, 1336625, 1366625

where $r_k(n)$ is the number of different squares $k$ (in this case, the sum of 2 different squares) that add up to $n$. (Source)

I have noticed that all of these are divisible by $5^2$, but I know that the answer to this problem ends in 309.

What kinds of numbers would get me 420 for this?

  • $\begingroup$ Why do you know the last digits of the answer, where is the problem from? $\endgroup$
    – Listing
    Feb 11, 2012 at 21:28
  • $\begingroup$ This is for a math/programming problem that was given to me. I was given the answer and asked to make a program that gives me that answer for the question. $\endgroup$
    – Awk34
    Feb 11, 2012 at 21:30
  • 1
    $\begingroup$ @Awk: I checked a few, they were OK. The smallest not divisible by $25$ will be $(5)(13^3)(17^2)$. You will have to make sure not to forget, for example, $(5^7)(13^3)$. $\endgroup$ Feb 12, 2012 at 18:59
  • 1
    $\begingroup$ For those interested in the source for this problem, it is Euler Project Problem 233. $\endgroup$
    – user26300
    Mar 5, 2012 at 9:22
  • 1
    $\begingroup$ If, as @user26300 indicated, this question came from Project Euler, this meta discussion would be relevant. $\endgroup$ Mar 5, 2012 at 9:54

1 Answer 1


Hint: use the following well-known formula

$\qquad\quad n = 2^{c} p_1^{a_1}\:\cdots\:p_r^{a_r} q_1^{b_1}\:\cdots\:q_s^{b_s}\quad$ where primes $\ p_i \equiv 3,\ q_i \equiv 1\pmod{4}$

$\quad\ \Rightarrow\ {\rm SquaresR}[2,n] = 4\:(b_1+1)\:\cdots\:(b_s+1)\:$ if $a_i$ are all even, else $0$

  • $\begingroup$ Sorry, but I already am using that formula. I just wanted to know how I could narrow it down to where my answers would be 420. $\endgroup$
    – Awk34
    Feb 12, 2012 at 0:17
  • $\begingroup$ This was in reply to the first version of your question, which did not have the link. Apply the formula and solve for the $b_i$. $\endgroup$
    – Math Gems
    Feb 12, 2012 at 0:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.