Is it true that all elements in $\mathbb{Z}/n\mathbb{Z}$ are representable as the sum of a square and a cube?

Example: ($n=7$)

$0 \equiv 0^2+0^3 \left( \text{mod } 7 \right)$

$1 \equiv 1^2+0^3 \left( \text{mod } 7 \right)$

$2 \equiv 1^2+1^3 \left( \text{mod } 7 \right)$

$3 \equiv 2^2+3^3 \left( \text{mod } 7 \right)$

$4 \equiv 5^2+0^3 \left( \text{mod } 7 \right)$

$5 \equiv 2^2+4^3 \left( \text{mod } 7 \right)$

$6 \equiv 0^2+6^3 \left( \text{mod } 7 \right)$

It is trivial to see that $0$, $1$, $2$, and $\left( n-1 \right)$ can be represented as the sum of a square and a cube. This is accomplished when considering the combinations like $\left( 0^2+0^3 \right)$, $\left( 0^2+1^3 \right)$, $\left( 1^2+0^3 \right)$, etc.

How can I prove this?


There is a slightly stronger version which states that all elements can be written as $a^2+b^3$, where $a \ne b$. I have verified this stronger version up to $n=1000$.

  • $\begingroup$ how do you get $7$ as the sum of a square and a cube in just $\mathbb{Z}$? $\endgroup$ Sep 11, 2013 at 22:34
  • $\begingroup$ Ryan, the suggestion seems to be that you are doing this in the ring of integers $\pmod n.$ If so, could you display all your solutions for $n=20,$ show all $j \equiv x^2 + y^3 \pmod {20}$ with $1 \leq j \leq 19?$ $\endgroup$
    – Will Jagy
    Sep 11, 2013 at 23:01
  • 2
    $\begingroup$ By the Chinese Remainder Theorem, it suffices to decide this problem with $n$ a prime or prime power. It is very likely true for all primes, as half the residues are squares, and at least a third of residues are cubes. Less sure about $n=p^2, n=p^3,$ etc. $\endgroup$
    – Will Jagy
    Sep 11, 2013 at 23:10
  • 1
    $\begingroup$ Also, representing $n-2$ will not always be obvious. $\endgroup$
    – Will Jagy
    Sep 11, 2013 at 23:26
  • 2
    $\begingroup$ @WillJagy If we have a solution modulo $p$, I think we can get solutions modulo $p^k$ from Hensel's lemma. Depending on whether $p\neq2$ or $p\neq3$, hold $x$ or $y$ fixed and lift the other variable. Right? $\endgroup$ Sep 12, 2013 at 0:08

1 Answer 1


I prove it for $n=p$ a prime. After checking the cases $p=2$ and $p=3$ by hand, I suppose that $p>3$. Let $a \in \mathbf F_p$, we want to show that $a$ is the sum of a square and a cube. Without loss of generality we suppose $a \neq 0$. Let $E_a$ be the curve $$y^2 = x^3 +a.$$ over $\mathbf F_p$. Since $a \neq 0$, $E_a$ is an elliptic curve over $\mathbf F_p$. We have the following theorem (the so-called Hasse bound, or the Riemann hypothesis for elliptic curves over finite fields):

Theorem (Artin - Hasse) : Let $E/\mathbf F_p$ be an elliptic curve. Then $$|\#E(\mathbf F_p) - p - 1| \leq 2 \sqrt p.$$

Corollary: If $p>3$, then $\#E(\mathbf F_p)>1$, i.e. $E$ has a nontrivial rational point over $\mathbf F_p$.

Proof: If $\#E(\mathbf F_p) = 1$ then $p \leq 2 \sqrt p$ implies $p\leq 4$.

Corollary: If $p$ is prime, then every element of $\mathbf Z/p\mathbf Z$ is the sum of a cube and a square.

Proof: If $(x_0, y_0)$ is a nontrivial point on $E_a$ then $y_0^2 + (-x_0)^3 = a$.

Remark: Your other question, concerning the existence of a solution with $x_0 \neq y_0$, can be answered positively using Bézout's theorem. The line $y=x$ intersects $E_a$ in at most $3$ points, so for $p$ large enough, Artin-Hasse still guarantees the existence of a solution with $x_0 \neq y_0$. (I'll let you figure out the right bound on $p$.)

  • 3
    $\begingroup$ For prime powers you can show that mod $p$ there is a solution that is not $(0,0)$ if $a \neq 0$ or $p \ge 11$. Then for any lift of $a$ mod $p^n$ you can lift that solution mod $p^n$ $\endgroup$
    – mercio
    Sep 27, 2013 at 16:16
  • 3
    $\begingroup$ Dear @mercio I think that you are right, but I suppose one might have to be careful for $p=2$ and $p=3$. If you'd like to work out the details, feel free to edit them into my post. Regards, $\endgroup$ Nov 15, 2013 at 5:00
  • 1
    $\begingroup$ The case of primes powers for $p < 11$ needs extra care. A solution covering all prime powers is in my answer to mathoverflow.net/questions/134352/… $\endgroup$
    – KCd
    May 21, 2014 at 0:49
  • $\begingroup$ @KCd Very nice, thanks! $\endgroup$ Jun 6, 2014 at 2:49

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.