We're almost in 2017. I wonder how many pairs of integer solutions has the following diophantine equation:

$$x^2 + y^2 = (2017)^3$$

Thanks in advance.

  • 27
    $\begingroup$ Since 2017 is not yet come, you still have time to think about it and tell us your efforts! $\endgroup$
    – Maffred
    Dec 28, 2016 at 0:09
  • 3
    $\begingroup$ @Maffred nice comment xd. $\endgroup$
    – Xam
    Dec 28, 2016 at 0:10
  • 6
    $\begingroup$ wow, my answer got $6$ upvotes and it was wrong, good to see you all love me though :) $\endgroup$
    – Asinomás
    Dec 28, 2016 at 0:13
  • 1
    $\begingroup$ Using brute force one can find that the only solutions $(x,y)$ satisfying $0 \le x \le y$ are $(18153, 88748)$ and $(51543, 74492)$. Hence in total there are 16 integer solutions. $\endgroup$
    – Crostul
    Dec 28, 2016 at 0:27
  • 2
    $\begingroup$ There is a well-known lemma (see Cox, primes of the form $x^2+ny^2$) stating that the number of integer solutions of $x^2+y^2=n$ is four times the difference between the number of divisors of $n$ of the form $4k+1$ and the number of divisors of $n$ of the form $4k+3$. Since $2017$ is a prime of the form $4k+1$, there are $16$ solutions. $\endgroup$ Dec 28, 2016 at 1:45

5 Answers 5


Without loss of generality, let's say $x < y$. Thus, $2x^2 < x^2+y^2=2017^3$, meaning $x < \sqrt{\frac{2017^3}{2}} < 64054$. Thus, just test all of the integers $x$ from $x=0$ to $x=64053$. Here's the Python code for this problem and the program's output.

>>> from math import sqrt
... for x in range(64054):
...     y = int(sqrt(2017**3-x**2))
...     if x*x*+y*y == 2017**3: print(x, y)

18153 88748
51543 74492

Thus, we have: $$(x, y) \in \{(\pm 18153,\pm 88748), (\pm 51543,\pm 74492), (\pm 74492,\pm 51543), (\pm 88748,\pm 18153)\}$$

  • $\begingroup$ @AlexWertheim Thanks for the catch! $\endgroup$ Dec 28, 2016 at 0:25
  • 2
    $\begingroup$ Sure! Of course, each component can be negative, so you'd have to include those as well. But maybe it'd be easiest to write $(\pm x, \pm y)$. $\endgroup$ Dec 28, 2016 at 0:26
  • $\begingroup$ @AlexWertheim Oh, thanks again! $\endgroup$ Dec 28, 2016 at 0:27

Noble Mushtak's solution is a quick way to solve this problem completely using a computer. What I will try to present here is a method for finding a solution that can be done a little more simply.

We know that $2017$ is a prime number. Thus, the factorization of $2017^3$ is just that: $2017^3$.

By Fermat's theorem on two squares, $2017$ is expressible as the sum of two squares, since $2017\equiv 1 (\operatorname{mod} 4)$. This can be done by hand relatively easily: the only solution to $a^2+b^2=2017$, excluding trivial rearrangments, is:


Consider $(2017\cdot 9)^2+(2017\cdot 44)^2$. We can factor out $2017^2$, so this gives


and knowing the value of the sum of squares, this is just


Thus, we have quickly found a solution

$(2017\cdot 9)^2+(2017\cdot 44)^2=2017^3$,

matching up with one of the solutions the programs gave.

There are other primitive solutions to this equation; this method won't give them, but it is a quick way to solve the problem by hand. A consequence of this is that given any integer $n$ such that there exists a Diophantine solution to


$n^3$ can be decomposed as well (and in an easily constructible way).


Borrowing from this answer here

The answer is just $\frac{3+1}{2}=2$. ( or $4$ if the order matters).

I checked it with this code:

#include <bits/stdc++.h>
using namespace std;
typedef long long lli;

lli N=2017;

int isq(lli N){
    lli s=sqrt(N);
    if(s*s==N) return(1);

int main(){
    int res=0;
    for(lli i=0;i*i<N;i++){
        if(isq(N-i*i) ) res++;

For future reference, if you just enter

m^2 + n^2 = (2017)^3

into Mathematica (or WolframAlpha) then it returns all integer solutions:

enter image description here


I want to share with everyone that I just found an algebraic method to calculate primitive triples in my specific case of raising to the third power:


I do not know why but on specialist internet sites this is not often found.

Happy new year for all.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .