0
$\begingroup$

I am learning Legendre's three-square theorem , to check if a number can be written in a 3 square form.

I have to check if the number is in the form $4^{a}(8b+7)$.

How to do this efficiently ? For odd the answer is no.

  • 3
    Divide by 4 until the number is no longer divisible by 4. Then check the remainder modulo 8.2017-01-10
  • 0
    It is relatively easy to show that no number of the form $4^a(8b+7)$ is a sum of three squares, but it is more difficult to show that all other numbers are a sum of three squares.2017-01-10
  • 0
    @Peter i am asking how to check2017-01-10
  • 0
    Are you asking for an algorithm approach?2017-01-10

1 Answers 1

1

If a number is a sum of $3$ squares, it cannot be of the form $4^a(8b+7)$

Proof :

Suppose, $N=4^a(8b+7)=u^2+v^2+w^2$

Every perfect square is congruent $0$ or $1$ modulo $4$, so $u,v,w$ must be even, as long as $a>0$. Therefore, we can divide by $4$ until we get

$8b+7=u'^2+v'^2+w'^2$

But this cannot hold because every perfect square is congruent to $0,1$ or $4$ modulo $8$