Suppose $p$ and $q$ are prime numbers, and $n>1$ is a positive integer. Find all solutions to the following Diophantine equation:$$(p+q)^q-p^q-q^q+1=n^{p-q}$$

What I have tried:

Obviously $p>q$. If $q=2$, we get one solution: $(p, q, n)=(3, 2, 13)$. From now on $p>q>2$. Letting $p-q=2^k r$, where $r$ is an odd number and working on the evaluation of $2$ in the equation gives $k=1$.

I think that $r=1$ is the only possibility. But I don't know how to prove it! I tried to show that $r$ cannot have a prime divisor, but I failed!

Looking mod $p$, $q$ and $p+q$ gives $n^{p-q} \equiv 1 \pmod {pq^2(p+q)}$.

Edit: Let's put a new restriction on the equation: Order of $n$ modulo $p$ is $p-q$. If you work on equation with the new constraint, please inform me about your results!

Notice that $n^{p-q} \equiv 1 \pmod p$, so $\gcd(n, p)=1$ and it follows from the Fermat's little theorem that $n^{p-1} \equiv 1 \pmod p$. Order of $n$ modulo $p$ is $p-q$, hence $p-q|p-1$ and consequently $p-q|q-1$.

  • 1
    $\begingroup$ Maybe it is worth pointing out that $q$ is a Wieferich prime base $n$: en.wikipedia.org/wiki/…. This follows from the lemma that I state in my answer here: math.stackexchange.com/questions/25849/…. With $k$ being the order of $n$ modulo $q$, then lemma shows that $n^k = 1$ modulo $q^2$ since otherwise the order of $n$ modulo $q^2$ would be divisible by $q$. Your work shows that this order divides $p-q$, which is relatively prime to $q$. $\endgroup$ May 31, 2016 at 22:20
  • 3
    $\begingroup$ It looks like $(p,q,n) = (5,3,19)$ is another solution, which might inform you of modular restrictions being insufficient in some cases. $\endgroup$
    – Erick Wong
    Jun 3, 2016 at 5:19
  • 1
    $\begingroup$ Why didn't you link to your other extremely similar question math.stackexchange.com/questions/1805633/…? $\endgroup$
    – Erick Wong
    Jun 5, 2016 at 6:34
  • $\begingroup$ I'll do it! That one was deleted! I wanted to mention someone there, so reopened it! $\endgroup$
    – Ghartal
    Jun 5, 2016 at 6:38

1 Answer 1



Let $p-q=\alpha$


Since q is odd, number of terms of expansion $(p+q)^q$ is even and terms $p^q$ and $q^q$ will be eliminated on LHS and the remained polynomial has a factor like $[p.q(p+q)]$ which is even.On RHS we have a factor like $n-1$ which indicates n must be odd, in fact we have:

$$p.q (p+q).P(p, q)= (n-1)(n^{\alpha -1}+n^{\alpha -2}+n^{\alpha -3}+ . . .)$$

Where $P(p, q)$ denotes a polynomial having parameters p and q. This can help us to choose the number for n to be checked. For example with $p=5 $ and $q=3$ we may write:

$$(5+3)^3-5^3-3^3=3(3\times 5)(3+5)=18\times 20=n^2-1=(n-1)(n+1)$$

So $q=19$ works.If $p=2k_1-1$ and $q=2k_2+1 $, we have:

$$C^q_r (2k_1-1)(2k_2+1)(2k_1+2k_2)=(n-1)\Sigma^{\alpha-1}_{r=1}n^{\alpha - r}$$

Now for selecting p and q we must consider that the difference between p and q must be such that we can construct a relation it's sides have close values, for example consider primes $p=47$ and $q=7$, we have:


Number of digits of $54^7$ is :

$N_d=7 \log 54 = 13$ so n must be such that it's 7th power has approximately 13 digits or we must have:

$\log n ≈ \frac{13}{7} $$n ≈ 100$

Now on LHS we have:

$(2\times 47= 94)(26)(7)=4\times47 (7\times13=91) $

Numbers 91 and 94 are closed to 100, but n must be odd so number 95 can be selected for test.

  • 1
    $\begingroup$ -1 This does not answer the question (Find all solutions...), this would be fine as a comment. $\endgroup$ Feb 15, 2019 at 17:50
  • $\begingroup$ @Servaes, but it helps to develop an algorithm for solving problem. you can take part in doing that instead of down voting an attempt for a solution! $\endgroup$
    – sirous
    Feb 16, 2019 at 5:12
  • $\begingroup$ Also, what do you mean by ...a factor like $[p.p(p+q)]$...? And what is $C_r^q$? $\endgroup$ Feb 16, 2019 at 10:04
  • $\begingroup$ @Servaes, it was a typo, I corrected it. $\endgroup$
    – sirous
    Feb 16, 2019 at 10:08
  • 1
    $\begingroup$ Then what is $r$ in $C_r^q$? And yes; that is precisely the question, to find all solutions. And you are right, that's a typo in the second relation, it should of course be $$n^{p-q}-1=(p+q)^q-p^q-q^q.$$ $\endgroup$ Feb 16, 2019 at 10:22

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.