Skip to main content.

Solution to puzzle 142: Sum of two nth powers

Skip restatement of puzzle.Let a, b, n, and m be positive integers, with n > 1.  Show that an + bn = 2m implies a = b.


We write a = 2rp and b = 2sq, for some non-negative integers r and s, and odd integers p and q.
We thus have (2rp)n + (2sq)n = 2m.
Without loss of generality, assume r less than or equal to s, so that pn + (2s−rq)n = 2m−nr.
Since both terms on the left-hand side of the equation are positive integers, the right-hand side must be greater than one, and hence even. 
Then pn odd implies (2s−rq)n odd implies r = s.
Hence we may cancel the factor 2r from a and b, obtaining pn + qn = 2t, for some positive integer t.

Our aim is to show that p = q = 1.  We consider odd and even n separately.

n is odd

We assume not both p and q are equal to 1.
Since n is odd, p + q is a factor of pn + qn.
If C = pn + qn = 2t, then
A = p + q = 2u, for some positive integer u, and
B = pn−1 − pn−2q + pn−3q2 − pn−4q3 + ... + qn−1 = 2t−u,
and clearly, since C > A, we have B > 1, t > u, and so B is even. 

But then B is the sum of an odd number of odd terms, and so is odd, a contradiction.

We conclude that the only possible solution is p = q = 1.

n is even

Writing n = 2w, we have (pw)2 + (qw)2 = 2t, and it will be sufficient to show that we must have pw = qw = 1, implying p = q = 1.
Since pw and qw are odd, their squares are congruent to 1, modulo 4.
Hence we have 1 + 1 = 2t (mod 4), implying t = 1.
Hence pw = qw = 1, and p = q = 1.

Conclusion

In both cases we conclude that p = q = 1, which is indeed a solution of pn + qn = 2t, with t = 1.
Hence, if an + bn = 2m, a = b = 2r is a solution.  (With nr + 1 = m.)

Therefore, an + bn = 2m implies a = b, as required.

Source: Inspired by Sum of two 23rd powers as a power of 2 on the projecteuler.net forum

Back to top