Find all pairs $(p,q)$ of prime numbers which $p>q$ and $$\frac{(p+q)^{p+q}(p-q)^{p-q}-1}{(p+q)^{p-q}(p-q)^{p+q}-1}$$is an integer.
Problem
Source: IMO Shortlist 2017 N5
Tags: number theory, IMO Shortlist
10.07.2018 14:30
Really straightforward for N5.
10.07.2018 15:26
For brevity let $a = p+q$ and $b = p-q$, so $a > b$ and $\gcd(a,b) \le 2$. Then we have in the usual way that \begin{align*} a^b b^a - 1 &\mid a^a b^b - 1 \\ \implies a^b b^a - 1 &\mid a^a b^b - a^b b ^a \\ &= (ab)^b \left( a^{a-b} - b^{a-b} \right) \\ \implies a^b b^a - 1 &\mid a^{a-b} - b^{a-b} \\ &= a^{2q} - b^{2q} \\ &= 4pq \cdot \frac{a^{2q}-b^{2q}}{a^2-b^2}. \end{align*} Claim: There are no solutions for $q \ge 5$. Proof. Assume $q > 2$. In that case $a$ and $b$ are even. Let $r = \sqrt{a^b b^a}$, meaning $r$ is even and $r^2-1$ divides the expression above. First, \begin{align*} r &= (p+q)^{\frac{1}{2}(p-q)} (p-q)^{\frac{1}{2}(p+q)} \\ \implies r &\equiv (-1)^{\frac{1}{2}(p+q)} q^p \pmod p \\ &\equiv (-1)^{\frac{1}{2}(p+q)} q \pmod p \end{align*}and since $p \ge q+2$, it follows $r \pm 1 \not\equiv 0 \pmod p$. Consequently $(r-1)(r+1)$ divides $T = q \cdot \frac{a^{2q}-b^{2q}}{a^2-b^2}$. However by cyclotomic arguments, all prime factors of $T$ are $1 \pmod q$ or $q$. So we conclude $r-1$ and $r+1$ are in $\{0,1\} \pmod q$. Hence $q \le 3$ as desired. $\blacksquare$ Now we grind through the $q=2$ and $q=3$ cases. For $q=2$, we arrive at \[ a^b b^a - 1 \mid 4(a+b) (a^2+b^2). \]If $p \ge 5$ then $a \ge 7$, $b \ge 3$ and so $a^b b^a \ge a^3 \cdot b^3 \cdot 3^4 > 16a^3b^3$ which is a contradiction. On the other hand $(p,q) = (3,2) \iff (a,b)=(5,1)$ is evidently a solution. Similarly, for $q=3$ we get \[ a^b b^a - 1 \mid 6(a+b)(a^4+a^2b^2+b^4) \]If $p \ge 11$ then $a \ge 14$, $b \ge 8$ and $a^b b^a \ge a^7 b^7 \cdot 8^6 > 36 a^7 b^7$ which is a contradiction. On the other hand neither $(p,q)=(5,3) \iff (a,b)=(8,2)$ nor $(p,q)=(7,3) \iff (a,b) = (10,4)$ are solutions, since: If $(a,b)=(8,2)$ then $a^b b^a = 2^{14}-1$, which is divisible by $43 \mid 2^7+1$. But $6(a+b)(a^4+a^2b^2+b^4) = 6 \cdot 10 \cdot 4368$ is not divisible by $43$. If $(a,b)=(10,4)$ then $a^b b^a = 10^4 \cdot 4^{10} - 1 = 320^4 - 1$, which is divisible by $11$ (dividing $319$). But $6(a+b)(a^4+a^2b^2+b^4) = 6 \cdot 14 \cdot 11856$, which is not divisible by $11$. In conclusion, the only solution is $(p,q)=(3,2)$ which visibly works.
10.07.2018 21:43
Quotes on this at PDC: "Remember kids, $n^2-1$ factors as $(n-1)(n+1)$." "Primes are odd". "Uh, except $2$ right?" "No one cares [insert person name]".
10.07.2018 22:59
Kind of boring, but ok as N5 Let $M = (p + q)^{p - q}(p - q)^{p + q} - 1$, then $M$ divides $(p + q)^{p + q}(p - q)^{p + q} - (p + q)^2q$. If the problem condition holds then it also divides $(p + q)^{p + q}(p - q)^{p + q} - (p - q)^2q$. Subtracting we find that $$M \mid (p + q)^{2q} - (p - q)^{2q}$$ Let $r$ be any prime dividing $M$. Then $r \mid (p + q)^{2q} - (p - q)^{2q}$ and $(p + q)^{2q} \equiv (p - q)^{2q} \pmod{r}$. Clearly $r$ is relatively prime to both $p + q$ and $p - q$ because it divides $M$. Then the previous congruence implies that $$\left(\frac{p + q}{p - q}\right)^{2q} \equiv 1 \pmod{r}$$ Implying that the order of $\frac{p + q}{p - q}$ divides $2q$. We assume for the moment that $q > 2$ and deal with this case at the end. Assume first that the order is not divisible by $q$. Then it divides $2$ and therefore $$(p + q)^2 \equiv (p - q)^2 \pmod{q} \implies r \mid 4pq$$ This implies that $r = 2$, $r = p$ or $r = q$. The first case is impossible because $q > 2$ implies that $p - q$ and $p + q$ are even and $M$ is odd. Now, if $r = p$ then $p \mid M$ implies that $$0 \equiv (p + q)^{p - q}(p - q)^{p + q} - 1 \equiv q^{2p} \pmod{p}$$ Implying that the order of $q \pmod{p}$ divides $2p$. Because it is at most $p - 1$ it follows that the order divides $2$ and $p \mid q^2 - 1 = (q - 1)(q + 1)$ which is impossible as $p \geq q + 2$. Finally if $r = q$ then similarly we find that $p^{2p} \equiv 1 \pmod{q}$ and the order of $p \pmod{q}$ must divide $2$, so $q \mid (p - 1)(p + 1)$ and $p = kq \pm 1$ for some positive integer $k$ and some choice of sign. Because both $p$ and $q$ are odd, it follows that $k$ is even. Now recall that $M$ must divide $(p + q)^{2q} - (p - q)^{2q}$. If $k \geq 4$ then the exponent of $p + q$ in $M$ is greater than $2q$, and $M > (p + q)^{2q} - (p - q)^{2q}$, contradicting that $M$ must divide this expression. Thus $k \leq 3$ and the only possibility is that $k = 2$. We now deal with these two cases. If $p = 2q + 1$. Then $M = (q + 1)^{3q + 1}(3q + 1)^{q + 1} - 1$ must divide $(3q + 1)^{2q} - (q + 1)^{2q}$, which implies that $(q + 1)^{3q + 1} \leq (3q + 1)^{q - 1}$. However this is false for every $q$ because $$(q + 1)^{3q} = ((q + 1)^2(q + 1))^q > (3(q + 1))^q > (3q + 1)^q > (3q + 1)^{q - 1}$$ If $p = 2q - 1$. Then $M = (q - 1)^{3q - 1}(3q + 1)^{q - 1} - 1$ divides $(3q - 1)^{2q} - (q - 1)^{2q}$. We must now have $(q - 1)^{3q - 1} \leq (3q - 1)^{q + 1}$, so we must have $(q - 1)^{3 - 1/q} \leq (3q - 1)^{1 + 1/q} \leq (4q - 4)^{1 + 1/q}$. The inequality now reduces to $$(q - 1)^{2 - 2/q} \leq 4^{1 + 1/q}$$ If $q \geq 5$ then $q - 1 \geq 4$ and we must have $2 - 2/q \leq 1 + 1/q$ which gives $q \leq 3$, a contradiction. If $q = 3$ then $p = 5$ which we easiy can prove doesn't satisfy the condition. In all remaining cases the order of $\frac{p + q}{p - q} \pmod{r}$ must be divisible by $q$, implying that $q$ divides $r - 1$, and therefore every prime divisor of $M$ is congruent to $1$ modulo $q$. Now, we have $$M = \left((p + q)^{\frac{p - q}{2}}(p - q)^{\frac{p + q}{2}} - 1\right)\left((p + q)^{\frac{p - q}{2}}(p -q)^{\frac{p + q}{2}} + 1\right)$$ Each of these factors must be congruent to $1 \mod q$ because all of their prime divisors is, but this is impossible because they differ by $2$ and $q$ is not $2$. Finally, if $q = 2$ then $M = (p + 2)^{p - 2}(p - 2)^{p + 2} - 1$ must divide $(p + 2)^4 - (p - 2)^4$. This is impossible for size reasons if $p \geq 7$. If $p = 5$ then $M = 7^33^7 - 1$ divides $7^4 - 3^7$ which once again doesn't hold for size reasons. Finally if $p = 3$ we find that $$\frac{5^51^1 - 1}{5^11^5 - 1} = \frac{3124}{4} = 781$$ Is an integer, so this is the only pair that works.
11.07.2018 01:53
Subtracting one from the fraction, we get $(p+q)^{p-q}(p-q)^{p+q}-1\mid [(p-q)(p+q)]^{p-q}[(p+q)^{2q}-(p-q)^{2q}]$. Now, if $r$ is a prime and divides $(p+q)(p-q)$, it cannot divide the LHS, so we get $$(p+q)^{p-q}(p-q)^{p+1}-1\mid (p+q)^{2q}-(p-q)^{2q}$$Thus, as a preliminary bound we get $p-q<2q$ or $p<3q$. From here on, assume $q>2$, so both $p,q$ are odd. Suppose $r$ is a prime that divides the LHS. Then $r$ divides the RHS and is relatively prime to $(p+q)(p-q)$, so we get $r\mid \left(\frac{p+q}{p-q}\right)^{2q}-1$. Now, if $q\nmid r-1$, we get $r\mid (p+q)^2-(p-q)^2=4pq$, so $r\in \{2,p,q\}$. But $2$ cannot divide the LHS, so we are limited to $r=p$ or $r=q$. Suppose $r=p$; then $p\mid (p+q)^{p-q}(p-q)^{p+q}-1$ or $p\mid q^{2p}-1$. Thus $p\mid q^2-1=(q-1)(q+1)$, but this contradicts $p>q$. Thus, the only possibility is $r=q$. Otherwise, $r\equiv 1\pmod{q}$. Thus, every prime factor of the LHS is either $q$ or $1\pmod{q}$. On the other hand, if we write $X=(p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}}$, then the LHS can be written as $X^2-1$. On the other hand, every factor of $X^2-1$ is either $0$ or $1\pmod{q}$. Thus, $X-1, X+1\in \{0,1\}\pmod{q}$. The only way this can happen for $q>2$ is if $q=3$ and $X\equiv 2\pmod{3}$. Now, since $q=3$ we merely need to test $p<9$, or $p=5,7$. It is easy to check these cases fail. This exhausts all the cases for when $q$ is odd. Finally, checking $q=2$, we need $p<6$ or $p=3,5$. The only value of $p$ which works is $3$, and we get the ordered pair $\boxed{(3,2)}$.
17.07.2018 17:49
Let $A=(p+q)^{p+q}(p-q)^{p-q}-1, B=(p+q)^{p-q}(p-q)^{p+q}-1$. First we get that $q<p\leq3q$ as in the beginning of the first solution and also we do $q=2$ case work. Secondly we look at any prime divisor $t$ of $B$ and do some casework (excluding cases $t|(p+q)^2-(p-q)^2$ and $t|((p^2-q^2)^2-1$), after what we get that $t \equiv 1 \mod pq$. Here one can get stucked if he don't notice a simple fact that $B$ if of the form $n^2-1$. But there is a brute force finish in this case. Let's look. Every prime of $B$ has remainder $1$ modulo $pq$, so $B$ itself has remainder $1$ modulo $pq$. $B \equiv 1 \mod p$ means $p|q^{2p}-2$ or $p|q^2-2$, so $q^2-2=sp$ with an integer $s$. Futher, $B \equiv 1 \mod q$ means $p^{2p}\equiv 2 \mod q$, hence $p^{-2}\equiv p^{2(q^2-2)}=p^{2sp}\equiv 2^s \mod q$, or, equivalently, $p^2\equiv 2^{-s} \mod q$. Taking each part of congruence into degree $p$ we get $-2^{sp}\equiv p^{2p} \equiv 2 \mod q$, so $q|2^{sp-1}+1$. If $r$ is order of $2$ modulo $q$ then $r|(2(q^2-3),(q-1))\leq 4$, so the only thing left to do is to check primes $q|15$.
13.06.2020 09:31
Suppose $q\not = 2$ for now. Let $a=p+q,b=p-q$. Then $a^bb^a-1\mid a^ab^b-1$, so $a^bb^a-1\mid a^ab^b-a^bb^a = a^bb^b(a^{a-b}-b^{a-b})$. But $\gcd(a^bb^a-1,a^bb^b)=1$, so $a^bb^a-1\mid a^{2q}-b^{2q}$. Suppose a prime $r$ divides $a^bb^a-1$. Note that $r$ is odd since $a,b$ are even. Then $r\mid a^{2q}-b^{2q}$, so the order of $a/b$ mod $r$ divides $2q$, so it is in the set $\{1,2,q,2q\}$. If the order is 1 or 2, then $a^2\equiv b^2 \pmod{r}$, i.e. $(p+q)^2-(p-q)^2=4pq \equiv 0 \pmod{r}$, so $r \in \{p,q\}$. However, if $r=p$, then \[ 0\equiv (p+q)^{p-q}(p-q)^{p+q}-1\equiv q^{p-q}\cdot (-q)^{p+q}-1 \equiv q^{2p}-1 \equiv q^2-1 \pmod{p} \]which is not possible, since $p>q$. If $r=q$, then \[ 0\equiv (p+q)^{p-q}(p-q)^{p+q}-1 \equiv p^{p-q}\cdot p^{p+q}-1 \equiv p^{2p}-1\pmod{q}.\]Now the order of $p \pmod{q}$ divides $2p$, so it is in the set $\{1,2,p,2p\}$. It also divides $q-1$, which is a contradiction if the order is $p$ or $2p$, which means the order of $p\pmod q$ is 1 or 2. But then $p^2\equiv 1 \pmod{q}$, so $q\mid (p-1)(p+1)$, contradiction. Therefore, the order of $a/b$ mod $r$ is $q$ or $2q$. But it also divides $r-1$, so $q\mid r-1$. Hence, $r\equiv 1 \pmod{q}$, so every prime factor of $a^bb^a-1$ is $q$ or 1 mod $q$. But $a,b$ are even, so $a^bb^a=k^2$ for some $k$. So $a^bb^a-1=(k-1)(k+1)$, which means every prime factor of $k-1,k+1$ are 0,1 mod $q$, and in particular $k-1,k+1$ are both 0 or 1 mod $q$. This is impossible unless $q=2$ or $q=3$. We conclude that $q \in \{2,3\}$. A check on these both gives that the only solution is $(p,q)=(3,2)$.
27.12.2020 04:38
Solved with nukelauncher. Since the denominator is relatively prime with \(p+q\) and \(p-q\), it is equivalent to note that \[\frac1{(p+q)^{p-q}(p-q)^{p-q}}\left(\frac{(p+q)^{p+q}(p-q)^{p-q}-1}{(p+q)^{p-q}(p-q)^{p+q}-1}-1\right)=\frac{(p+q)^{2q}-(p-q)^{2q}}{(p+q)^{p-q}(p-q)^{p+q}-1}\]is an integer. The only pair that works is \((3,2)\). We can easily verify this is the only solution for \(q\le3\) by applying the following claim and finite-case checking: Claim: \(p<2q\) Proof. We know that \((p+q)^{p-q}(p-q)^{p+q}-1\) divides \((p+q)^{2q}-(p-q)^{2q}\). But if \(p\ge2q\), then \[(p+q)^{p-q}(p-q)^{p+q}-1\ge(p+q)^{2p-2q}-1\ge(p+q)^{2q}-(p-q)^{2q},\]absurd. \(\blacksquare\) Henceforth assume \(q\ge5\). Then \(p+q\) and \(p-q\) are even, so define \[s:=(p+q)^{(p-q)/2}(p-q)^{(p+q)/2}-1.\]Let \(r\) be a prime dividing \(s^2-1\), so \(r\) divides \((p+q)^{p+q}(p-q)^{p-q}-1\). Claim: Either \(r=q\) or \(q\) divides \(r-1\). Proof. Recall that \(s^2-1\) divides \((p+q)^{2q}-(p-q)^{2q}\), so \[\left(\frac{p+q}{p-q}\right)^{2q}\equiv1\pmod r.\]It follows that \(\operatorname{ord}_r(\frac{p+q}{p-q})\in\{1,2,q,2q\}\). If \(\operatorname{ord}_r(\frac{p+q}{p-q})\in\{q,2q\}\), then \(q\mid r-1\). Otherwise \(\operatorname{ord}_r(\frac{p+q}{p-q})\in\{1,2\}\), and so \[r\mid\left(\frac{p+q}{p-q}\right)^2-1\mid(p+q)^2-(p-q)^2=4pq.\] Since \(s^2-1\) is odd, \(r\ne2\). If \(r=p\), then \[0\equiv s^2-1\equiv q^{2p}-1\equiv q^2-1\pmod p,\]so \(p\) divides either \(q-1\) or \(q+1\). This is absurd by \(p>q\). Hence \(r=q\). \(\blacksquare\) It follows that both \(s-1\) and \(s+1\) are either 0 or 1 modulo \(q\). This is impossible under our assumption that \(q\ge5\).
27.12.2020 10:53
MarkBcc168 wrote: Find all pairs $(p,q)$ of prime numbers which $p>q$ and $$\frac{(p+q)^{p+q}(p-q)^{p-q}-1}{(p+q)^{p-q}(p-q)^{p+q}-1}$$is an integer. Not so great of a problem but quite ok for N5. \begin{align*} (p + q)^{p - q}(p - q)^{p + q} - 1 &\mid (p + q)^{p + q} (p - q)^{p - q} - 1 \\ (p + q)^{p - q} (p - q)^{p + q} - 1 &\mid (p + q)^{p + q} (p - q)^{p - q} - (p + q)^{p - q} (p - q)^{p + q} \\ (p + q)^{p - q} (p - q)^{p + q} - 1 &\mid (p + q)^{p - q} (p - q)^{p - q} ( (p + q)^{2q} - (p - q)^{2q} ) \\ (p + q)^{p - q} (p - q)^{p + q} - 1 &\mid (p + q)^{2q} - (p - q)^{2q} \end{align*}Claim 01. $p < 3q$. Proof. Notice that $(p + q)^{2q} > (p - q)^{2q}$, and by divisibility criteria, we have \[ (p + q)^{p - q} - 1 \le (p + q)^{p - q}(p - q)^{p + q} - 1 \le (p + q)^{2q} - (p - q)^{2q} \le (p + q)^{2q} - 1 \]Therefore, we conclude that $p - q \le 2q$, but since $p$ and $q$ are both primes, we conclude that $p < 3q$. Claim 02. If $q = 2$, then the only solution is $(3,2)$. Proof. By the previous claim, we have $p \le 3q$, so we just need to check $(3,2)$ and $(5,2)$. Notice that $(3,2)$ obviously satisfies, and therefore $(3,2)$ is a solution. Now, we may assume that $p > q \ge 3$ are both odd, and therefore $p + q$ and $p - q$ are both even. Claim 03. If $r \mid (p + q)^{p - q} (p - q)^{p + q} - 1$, then either $r = q$ or $r \equiv 1 \ (\text{mod} \ q)$. Proof. We have \[ r \mid (p + q)^{p - q} (p - q)^{p + q} - 1 \mid (p + q)^{2q} - (p - q)^{2q} \]Then, we have $o_r \left( \frac{p + q}{p - q} \right) \mid 2q$. Suppose that $q \nmid o_r \left( \frac{p + q}{p - q} \right)$, then we have \[ r \mid (p + q)^2 - (p - q)^2 = 4pq \]For obvious reason, $\gcd(r,4) = 1$ since $(p + q)^{p - q} - (p - q)^{p + q}$ is even. Now, we have $r = p$ or $r = q$. If $r = p$, then \[ p \mid (p + q)^{p - q} (p - q)^{p + q} - 1 \Rightarrow p \mid q^{2p} - 1 \]By Fermat Little Theorem, $p \mid (q^p)^2 - 1$, and therefore $p \mid q^2 - 1$. However, we know that $p \ge q + 2$ and $p \mid (q - 1)(q + 1)$. This is a contradiction. We now have that for all primes $r$ such that \[ r \mid (p + q)^{p - q} (p - q)^{p + q} - 1 \]then $r \equiv 0, 1 \ (\text{mod} \ q)$. For me, this is the trickiest part of the solution, as everything else flows naturally: Let $N = (p + q)^{\frac{p - q}{2}} (p - q)^{\frac{p + q}{2}}$, which is an integer since $p - q$ and $p + q$ are both even. Therefore, \[ r \mid N^2 - 1 \Rightarrow r \mid (N - 1)(N + 1) \]Now, we conclude that $\{ N - 1, N + 1 \} \equiv \{ 0, 1 \} \ (\text{mod} \ q)$. Now, notice that $(N + 1) - (N - 1) \in \{ 1, 0, -1 \} \ (\text{mod} \ q)$. This pretty much gives us $q \le 3$. Since we have $q \ge 3$, this forces $q = 3$. Hence, from our first claim, we just need to check $p < 3q = 9$, which means we just need to check $(5,3)$ and $(7,3)$, both of which don't work. Remark. This problem is really intimidating, yet the housekeeping (standard order stuffs to simplify things) did most of the tricks. However, this thing is quite popular among order problems: that if you conclude that the prime divisors of $a$ is either $0$ or $1$ modulo $q$, then $a$ must be either $0$ or $1$ modulo $q$. Once you realized that $(p + q)^{p - q} (p - q)^{p + q} - 1 = N^2 - 1$ for some $N \in \mathbb{N}$, we are pretty much done.
30.12.2020 15:25
The answer is $(p,q)=(3,2)$, which obviously works. We now show that it is the only solution. Notice that $p+q, p-q$ are both relatively prime with the denominator. As a result, \begin{align*} 1&\equiv(p+q)^{p+q}(p-q)^{p-q}\\ &\equiv(p+q)^{p-q}(p-q)^{p+q}(p+q)^{2q}(p-q)^{2q}\\ &\equiv\left(\frac{p+q}{p-q}\right)^{2q}\pmod{(p+q)^{p-q}(p-q)^{p+q}-1}\\ \end{align*}This implies $$(p+q)^{p-q}(p-q)^{p+q}-1|(p+q)^{2q}-(p-q)^{2q}\hspace{20pt}(1)$$In particular, we have $(p+q)^{p-q}\leq (p+q)^{2q}$, therefore, $p\leq 3q$, so if $q=2$ then the only solution is $p=3$. Now supppose $q$ is odd. CLAIM 1. $p<2q$. Proof. Suppose $p\geq 2q$, then from $(1)$ we have $$(p-q)^{p+q}\leq (p+q)^{3q-p}\leq (p+q)^q$$Let $p=kq$, then $$(k-1)^{p+q}q^q\leq (k+1)^q$$Notice that $k<3$, therefore $q=3$, from which we easily check that there is no solution. $\blacksquare$ CASE I: $q|(p+q)^{p-q}(p-q)^{p+q}-1$. Then $q|p^{2p}-1$. Notice that the $\text{ord}_q(p)|q-1$, therefore, it can only be $2$. This implies $p\equiv \pm 1\pmod q$ Therefore, $p=2q-1$, the equation becomes $$(3q-1)^{q-1}(q-1)^{3q-1}-1|(3q-1)^{2q}-(q-1)^{2q}$$hence $(q-1)^{3q-1}\leq (3q-1)^{q+1}$, but by easy induction we have $(q-1)^{3q-1}>(3q-1)^{q+1}$ for $q\geq 5$, contradiction. CASE II: $q\nmid (p+q)^{p-q}(p-q)^{p+q}-1$ Suppose $r$ is a prime such that $r|(p+q)^{p-q}(p-q)^{p+q}-1$ CLAIM 2. If $r\neq p$ then $r\equiv 1\pmod q$ Proof. Since $(p+q)^{p-q}(p-q)^{p+q}-1$ is odd, $r\neq 2$. Notice that $r\neq p,q$ by assumption, moreover, $$1\equiv\left(\frac{p+q}{p-q}\right)^{2q}\pmod r$$Let the order of $\displaystyle\left(\frac{p+q}{p-q}\right)$ modulo $r$ be $d$, notice that $r$ cannot be $2$ or otherwise $r|(p+q)^2-(p-q)^2$ which implies $r|4pq$, contradiction. Therefore, $q|d$, hence $q|d|r-1$ as desired. $\blacksquare$ Notice that $p-q,p+q$ are both even, let $a=(p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}}-1$, $b=(p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}}+1$. By LTE, $$v_p(ab)\leq v_p((p+q)^{2q}-(p-q)^{2q})=1$$Therefore, if $v_p(ab)=0$, then we have $a\equiv b\equiv 1\pmod q$, hence $q=2$ since $b-a=2$. Otherwise, one of $a,b$ is congruent to $1$ mod $q$ while the other is congruent to $p$ mod $q$, hence $p=q+3$ or $2q-1$, the former is impossible and the latter is rejected in CASE I.
13.04.2021 06:20
Some orders and bounding is enough to solve...
31.05.2021 22:27
Let $(p-q)^{p+q}(p+q)^{p-q} -1 = N$. Notice that the problem is equivalent to $(p+q)^{2q} - (p-q)^{2q} \equiv 0 \pmod N$ due to the fact that $(p,N) = (q,N)= 1$. And this implies that the order of the element $\frac{p+q}{p-q}$ is either $1,2,q,2q$ modulo $N (*)$. Now, we have $(p+q)^{p-q} < N \leq (p+q)^{2q} - (p-q)^{2q} < (p+q)^{2q}$, which means that $p < 3q$. Claim. $p \leq 2q$ or $q =2$ Suppose that $2q < p < 3q$. We now have that $(3q)^{q}(q)^{3q} < (p+q)^{p-q}(p-q)^{p+q} - 1 \leq (p+q)^{2q} - (p-q)^{2q} < (4q)^{2q} 3^q \cdot q^{4q} < 4^{2q} \cdot q^{2q} \implies 3q^4 < 16q^2 \implies 3q^2 < 16 \implies q = 2$ is the only possibility. Hence, the lemma follows. Now, we divide into the cases of the orders, as said in $*$. Let $r$ be a prime dividing $N$. If the order is $1$ or $2$, we have that $r | 4pq$, and hence $r$ is either $2,p,q$. If $q=2$ we have that $p < 6$, so we just need to try the values. From now on, we assume $q \geq 3$, and hence $N$ is odd, ,so $r$ is either $p,q$. $r$ can't be $q$ because $p>q$ and can't be $p$ because $p \leq 2q$ by the claim. Finally, if the order is $2q$ or $q$, we have that $2q | r-1$, which implies that every prime divisor of $N$ is of the form $1 + kq$ ,which implies $N \equiv 1 \pmod q$. But notice that $N$ is of the form $x^2 - 1$ for some $x$, and hence $(x-1)(x+1) \equiv 1 \pmod q$, which is not possible in this case. Hence, the only solution is $(3,2)$, which comes from $q=2$ and trying $p < 3q$.
23.09.2021 23:36
The answer is $(p,q)=(3,2)$, which works. Let $r$ be an arbitrary prime divisor of $(p+q)^{p-q}(p-q)^{p+q}-1$. Then, we must have $(p+q)^{p+q}(p-q)^{p-q} \equiv 1 \pmod{r}$. Thus, $$\frac{(p+q)^{p+q}(p-q)^{p-q}}{(p+q)^{p-q}(p-q)^{p+q}}=\left(\frac{p+q}{p-q}\right)^{2q} \equiv 1 \pmod{r}.$$If $\operatorname{ord}_r\left(\frac{p+q}{p-q}\right)$ is $1$ or $2$, then $(p+q)^2 \equiv (p-q)^2$, so $4pq \equiv 0 \mod r$. Therefore, either $r$ is even, $r=p$, or $r=q$. Otherwise, $q \mid \operatorname{ord}_r\left(\frac{p+q}{p-q}\right)$, so $r \equiv 1 \pmod{q}$. We have three cases. Case 1: $q=2$. Then, $(p+2)^{p-2}(p-2)^{p+2}-1 \mid (p+2)^{p+2}(p-2)^{p-2}-1$, so \[(p+2)^{p-2}(p-2)^{p+2}-1 \mid (p+2)^{p+2}(p-2)^{p-2}-(p+2)^{p-2}(p-2)^{p+2}.\]Thus, we have $$(p+2)^{p-2}(p-2)^{p+2}-1 \mid (p+2)^4-(p-2)^4.$$If $p \geq 7$, then we have a contradiction because of size. We obtain that $p=3$ gives the solution $(3,2)$ and $p=5$ fails due to size reasons. Now, assume henceforth that $p$ and $q$ are even. Case 2: $(p+q)^{p-q}(p-q)^{p+q}-1$ is divisible by $p$. Then, we have $$q^{p-q}(-q)^{p+q}=(-1)^{p+q}q^{2p} \equiv 1 \pmod{p}.$$Since $p$ and $q$ are even, we have $q^{2p} \equiv 1 \pmod{p}$, so $\operatorname{ord}_p(q) \mid \gcd(p-1,2p)=2$. Thus, $p \mid q^2-1$, so $p \mid \frac{q-1}{2}$ or $p \mid \frac{q+1}{2}$, which fails because $p>q$. Case 3: $(p+q)^{p-q}(p-q)^{p+q}-1$ is divisible by $p$. If $(p+q)^{p-q}(p-q)^{p+q}-1$ is divisible by $q$, then, we have $p^{2p}-1 \equiv 0 \pmod{q}$, so $\operatorname{ord}_p(q) \mid \gcd(q-1,2p)$. Since $p>q$, we see that $\gcd(q-1,2p)=2$. Thus, $q \mid p^2-1$, so $q \mid p-1$ or $q \mid p+1$. If $q \mid p-1$, the prime factorization of $(p+q)^{p-q}(p-q)^{p+q}-1$ must consist of $\pm 1 \mod{q}$ primes. Thus, we $(p+q)^{p-q}(p-q)^{p+q}-1 \equiv \pm 1 \pmod{q}$. Since $$(p+q)^{p-q}(p-q)^{p+q}-1=\left((p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}}-1\right)\left((p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}}+1\right),$$and both factors cannot be $1 \mod{q}$, we are done in this case. Otherwise $q \mid p+1$. We can do a similar Euclidean algorithm as in Case 1 to obtain that $p=2q-1$. Now, we are done by bounding.
24.12.2021 17:54
The difficulty is spotting the difference of squares, otherwise, I agree that this is rather straightforward for an N5.
24.01.2022 21:01
My answer is $(p,q)=(3,2)$. Suppose that $q>2$ so $p+q,p-q$ are eve, if we substract $1$ from the integer and remove the factors $p+q,p-q$ (we can do this because $p+q,p-q$ are coprimes with the denominator). We have that if $M = (p + q)^{p - q}(p - q)^{p + q} - 1$ then: $$M \mid (p + q)^{2q} - (p - q)^{2q}$$The key idea is the following: Key Claim: Let r be a prime divisor of $M$ then $r\equiv 1,0 \pmod{q}$ Proof: We have that: $$r \mid (p + q)^{2q} - (p - q)^{2q} \implies (\frac{p+q}{p-q})^{2q} \equiv 1 \pmod{r}$$Then $T= \operatorname{ord}_r\left(\frac{p+q}{p-q}\right)$ is divisor of $2q$ but also is divisor of $r-1$. But if $T$ is $q$ or $2q$ then $r\equiv 1 \pmod{q}$ And if $T$ is $1$ or $2$ then: $$(\frac{p+q}{p-q})^{2} \equiv 1 \pmod{r} \implies 4pq \equiv 0 \pmod{r}$$But $M$ is odd so $r=p$ or $r=q$. If $r=p$ then: $$p \mid (p + q)^{p - q}(p - q)^{p + q} - 1 \implies p \mid (q)^{p - q}(- q)^{p + q} - 1 \implies p \mid q^{2p} - 1$$So by FLT: $p \mid q^{2} - 1 \implies p \mid (q-1)(q+1)$ then $p \leq q+1$ but $p>q$ and $p,q$ are odd so $p-q \ge 2$ (Contradiction!) Then $r=q$ or $r\equiv 1 \pmod{q}$ $\square$. Finally the claim implies that all divisor of $M$ is $\equiv 1,0 \pmod{q}$ but $M$ have divisors: $$M=((p + q)^{\frac{p - q}{2}}(p - q)^{\frac{p + q}{2}} - 1)((p + q)^{\frac{p - q}{2}}(p - q)^{\frac{p + q}{2}}+1)$$Then exists two divisors of $M$ with difference $2$ and both are $\equiv 1,0 \pmod{q}$ so the difference is $2 \equiv 1,0,-1 \pmod{q}$ then the unique possible value of $q$ is $3$. Finally: $$M \mid (p + q)^{2q} - (p - q)^{2q} \implies M\leq (p + q)^{2q} - (p - q)^{2q} \implies M \leq (p + q)^{2q} - 1 \implies (p + q)^{p - q}(p - q)^{p + q} \leq (p + q)^{2q}$$So we have: $(p - q)^{p + q} \leq (p + q)^{3q-p} \implies p<3q$. If $q=3 \implies p<9$ if $p=7 \implies 4^{10} \leq 100$ obvious this is false. If $q=3,p=5$ then n the problem statement we replace: $ 2^{14}-1 \mid 2^{26}-1 \implies 14 \mid 26$ that is false. If $q=2$ then $p<6$ if $p=5 \implies 3^{7}\leq 7$ is false. Then the unique possible pair is $(p,q)=(3,2)$ that works.
24.06.2022 10:46
09.04.2023 21:33
The only pair is $(p, q) = (3, 2)$. Assume first that $p, q$ are both odd primes. Then, let some prime $r \mid (p+q)^{p-q}(p-q)^{p+q} - 1$. Then, using the divisibility condition and dividing, we have $$\left(\frac{p+q}{p-q}\right)^{2q} \equiv 1 \pmod r.$$Thus, either $q \mid r-1$ or $$(p+q)^2 \equiv (p-q)^2 \pmod r \iff r \mid 4pq.$$If $r = p$, then $$1 \equiv (p+q)^{p-q}(p-q)^{p+q} \equiv q^{2p} \pmod p,$$hence $p \mid q^{2p} - 1$, or $p \mid q^2 - 1$. But this is obviously impossible as $p, q$ are both odd primes. As a result, either $r=2$, which is impossible, or $r = q$. This crucially means that $(p+q)^{p-q}(p-q)^{p+q} - 1$ is the product of $q$ and $1 \bmod q$ primes. On the other hand, $$(p+q)^{p-q}(p-q)^{p+q} - 1 = ((p+q)^{(p-q)/2}(p-q)^{(p+q)/2}+1)((p+q)^{(p-q)/2}(p-q)^{(p+q)/2}-1),$$so each of these factors is $0$ or $1$ mod $q$. But this clearly implies $q \leq 3$. Assuming that $q = 3$, we can reduce to a finite case check by showing that $p < 2q$. However, this is evident by size reasons, as otherwise $$\gcd((p+q)^{p-q}(p-q)^{p+q} - 1, (p+q)^{p+q}(p-q)^{p-q} - 1) = \gcd((p+q)^{p-q}(p-q)^{p+q} - 1, (p+q)^{2q} - (p-q)^{2q}).$$When $p>2q$, the former expression is always greater, but this contradicts divisibility. Now, if $q=2$, testing cases and using the previous conclusion, we obtain $(3, 2)$ is the only solution.
07.06.2023 04:07
Let $a=p+q$ and $b=p-q$. We have \begin{align*} a^bb^a-1 &\mid a^ab^b-1 \\ a^bb^a-1 &\mid a^ab^b-a^bb^a \\ a^bb^a-1 &\mid a^bb^b(a^{a-b}-b^{a-b}) \\ a^bb^a-1 &\mid a^{2q} - b^{2q} \end{align*}Thus, $\left(ab^{-1}\right)^{2q} \equiv 1\pmod {a^bb^a-1}$. Let $r$ be the smallest prime dividing $a^bb^a-1$ then $g=\text{ord}_r(ab^{-1})\mid 2q$ and $g\mid r-1$. Suppose $q\ge 5$. Clearly, $r\neq 2$. If $g=1$ then $a\equiv b\pmod r$. If $g=2$ then $a\equiv -b\pmod r$. In the first case, $r\mid 2q$, so $r=q$. In the second, $r=p$. $r=p$ is clearly impossible since \[a^bb^a-1\equiv q^{p-q}q^{p+q}-1\equiv q^{2p}-1\equiv q^2-1\pmod p\]and $(q-1)$, $(q+1)$ are both coprime to $p$ since $p$ is a larger prime than $q$. If $g=q$ or $2q$ then $q\mid r-1$. Thus, the only prime factors of $a^bb^a-1$ are $0$ or $1 \pmod q$. Thus, any factor of $a^bb^a-1$ is also $0$ or $1\pmod q$. This is absurd, since $a^bb^a-1$ is one less than a perfect square and thus factors as $(t-1)(t+1)$ for some $t$, and one of them must break the $0$ or $1\pmod q$ rule. Suppose $q=3$. We have $a$ and $b$ are even, and so \[a^bb^a-1\mid a^6-b^6\implies a^bb^a-1\mid (a/2)^6-(b/2)^6\]If $p>9$ then $2b>a$ so surely $(a/2)^6-(b/2)^6 < (a/2)^6 < b^6 < b^a <a^bb^a-1$ which implies $a=b$, absurd. Thus, $p=7$ or $p=5$. It can be verified that neither works. Suppose $q=2$. We have $a$ and $b$ are both odd. We also have \[a^bb^a-1\mid a^4-b^4\]If $p>6$ then $b>4$ so $a^4-b^4<a^4\le a^b<a^bb^a-1$ and so $a=b$, again absurd. Thus, $p$ is $3$ or $5$, and it can easily be verified that $(3,2)$ is the only solution.
01.12.2023 02:46
For notational purposes, let $a = p+q$ and $b=p-q$. Observe that $a^bb^a \equiv 1 \pmod{a^bb^a - 1}$, from which the divisibility is equivalent to \[ (a^bb^a-1) \mid a^{2q}-b^{2q}. \]Let $p_0$ be an odd prime divisor of $a^bb^a-1$. Then \[ \left(\frac{a}{b}\right)^{2q} \equiv 1 \pmod{p_0}, \]so the order of $a/b$ modulo $p_0$ is one of $1$, $2$, $q$, and $2q$. We proceed to do casework on these possible orders. If the order is divisible by $q$, then $p_0 \equiv 1 \pmod{q}$. If the order is $1$ or $2$, then in either case we have \[ (p+q)^2 \equiv (p-q)^2 \pmod{p_0}, \]from which $p_0 = p$ or $p_0 = q$. If $p_0=p$, then \[ q^{2p} \equiv 1 \pmod{p}, \]so $p \mid q-1$ or $p \mid q+1$ by FLT. Neither are possible since $p>q$. Thus, each prime divisor of $a^bb^a-1$ is one of $q$ and $1 \pmod{q}$. In particular, $(a^bb^a-1)/q^{\nu_q(a^bb^a-1)}$ is $1 \pmod{q}$. Notice that we can write \[ p_0 \mid (a^{b/2}b^{a/2}-1)(a^{b/2}b^{a/2}+1) \]and realize that $p_0$ must divide exactly one of the two factors. Since each factor is in $\{0, 1\} \pmod{q}$, and their difference is $2$, we must have $q=2$ or $q=3$. To check which $p$ work along with these values of $q$, we first bound $p$. Claim: We have $p \le 2q$. Proof. Recall that $(a^bb^a-1) \mid a^{2q}-b^{2q}$ from our initial discussion. Then show that the LHS is greater than the RHS when $p > 2q$, so $p \le 2q$. Checking the resulting cases by hand returns $(3, 2)$ as the only solution.
24.01.2024 19:23
anantmudgal09 wrote: Quotes on this at PDC: "Remember kids, $n^2-1$ factors as $(n-1)(n+1)$." "Primes are odd". "Uh, except $2$ right?" "No one cares [insert person name]". Posting for comedic reasons, The key is to notice that $p^2-q^2=(p-q)(p+q)$ Notice then the equation rewrites as $(p+q)^{p-q}(p-q)^{p+q}-1 \mid (p+q)^{2q}-(p-q)^{2q}$ this also gives us the $p \leq 3q$ bound/ Let $a=p+q,b=p-q$ Claim:(Characterization of primes dividing $a^bb^a-1$) Every prime divisor $r$ of $a^bb^a-1$ must be of form $qk+1$ unless $p \equiv \pm 1 (\mod q)$
Suppose for now that every prime divisor is of form $qk+1$ then get a contradiction. then use some inequalities for $p = 2q \pm 1$ to get the only solution $(3,2)$
14.02.2024 16:15
Answer: $(p, q) = (2, 3)$ is the only solution. Firstly, we'll prove that there is no solution if $q > 3$. Assume $q > 3$. Let $T = (p+q)^{p-q}(p-q)^{p+q} - 1$. Then note that $(p+q)^{p+q}(p-q)^{p-q} \equiv 1 (T)$ and $(p+q)^{p-q}(p-q)^{p+q} \equiv 1 (T)$, so $\frac{(p+q)^{p+q}(p-q)^{p-q}}{(p+q)^{p-q}(p-q)^{p+q}} = (\frac{p+q}{p-q})^{2q} \equiv 1 (T)$. Since $T = (p+q)^{p-q}(p-q)^{p+q} - 1 = ((p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}} - 1)((p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}} + 1)$ and $(p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}} - 1 \equiv p^p - 1 (q)$, $(p+q)^{\frac{p-q}{2}}(p-q)^{\frac{p+q}{2}} + 1 \equiv p^p + 1 (q)$, hence either $p^p + 1 \not\equiv 0, 1 (q)$ or $p^p - 1 \not\equiv 0, 1 (q)$. Therefore, there exists a prime $r$ such that $r \mid T$ and $r \not\equiv 0, 1 (q)$. But we have $(\frac{p+q}{p-q})^{2q} \equiv 1 (T)$, which means $((\frac{p+q}{p-q})^{2q} \equiv 1 (r))$, so $(\frac{p+q}{p-q})^r \equiv 1 (r)$, or equivalently, $r \mid 4pq$, a contradiction. Now assume $q \le 3$. We split the problem into 2 cases: Case 1: $q = 2$. In this case, we have $(p+2)^{p-2}(p-2)^{p+2} - 1 \mid (p+2)^4 - (p-2)^4 = 16p(p^2 + 4)$. If $p \ge 5$, then $(p+2)^{p-2}(p-2)^{p+2} - 1 \ge (p+2)^3(p-2)^{p+2} - 1 \ge (p+2)^3 \cdot 2187 - 1 > 16p(p^2 + 4)$, so $p \le 3$, which forces $p = 3$ and we can easily check that $(2, 3)$ is a solution. Case 2: $q = 3$. If $p \ge 11$, then $(p+3)^{p-3}(p-3)^{p+3} - 1 \ge (p+3)^8 \cdot 5^11 - 1 > 36p(p^4 + 30p^2 + 81) = (p+3)^6 - (p-3)^6$, so $(p+3)^{p-3}(p-3)^{p+3} - 1 \nmid (p+3)^6 - (p-3)^6$, a contradiction. Hence $p$ equals $5$ or $7$ and one can check that $(3, 5)$ and $(3, 7)$ are not solutions. Hence we're done. $\blacksquare$
02.03.2024 08:13
Our only solution is $\boxed{(3,2)}$. Note that $q=2,3$ is just a finite case check due to size issues, giving us our claimed solution. We now assume $p,q \ge 5$, and suppose $r$ is an arbitrary prime divisor of the denominator, which also must divide the numerator. We then require \[(p+q)^{p+q} (p-q)^{p-q} \equiv (p+q)^{p-q} (p-q)^{p+q} \equiv 1 \pmod r\]\[\implies \left(\frac{p+q}{p-q}\right)^{2q} \equiv 1 \pmod r \implies k := \operatorname{ord}_r \left(\frac{p+q}{p-q}\right) \mid \gcd(2q,r-1) \mid 2q.\] First notice $r=2$ and $r=p$ both result in contradictions. Then \begin{align*} k=1,2 &\implies (p+q)^2 \equiv (p-q)^2 \pmod r \implies r=q \\ k=q,2q &\implies \gcd(2q,r-1) = q,2q \implies r \equiv 1 \pmod q. \end{align*} We finish by using difference of squares on the numerator to get two factors differing by 2 which must both be $0,1 \pmod r$, contradiction. $\blacksquare$
04.04.2024 22:09
The only solution is $(3,2)$, which works. Now we prove everything else fails. Suppose $(p,q)$ isn't $(3,2)$. Let $a = p+q, b = p-q$. Clearly $b > 1$. We have $a^b b^a - 1 \mid a^a b^b - 1$. Hence\[a^b b^a - 1 \mid a^a b^b - 1 - (a^b b^a - 1) = a^a b^b - a^b b^a\]Since $a,b$ are relatively prime to $a^b b^a$, we can divide the RHS by $(ab)^b$, so\[ a^b b^a - 1 \mid a^{a-b} - b^{a-b} = a^{2q} - b^{2q}\]Since $a > b$, we have that $a^b b^a - 1 < a^{a-b} - b^{a-b} < a^{a-b}$. Now since $b > 1$, $a^b b^a - 1 > a^b$, so $a^b < a^{a-b}$, meaning $a > 2b$. Hence $p + q > 2p - 2q$, so $p < 3q$. Case 1: $q >3$. Then $p > q \ge 5$. Claim: $a^b b^a - 1$ has some prime factor that is not $1\pmod q$. Proof: Suppose otherwise. Then all divisors of $a^b b^a - 1$ are $1\pmod q$. Then notice that $a,b$ are both even, so $a^b b^a$ is a perfect square. Let $x^2 = a^b b^a$, we have that $(x-1)(x+1) = a^b b^a - 1$, so $x -1$ and $x + 1$ are $1\pmod q$, implying $q = 2$, contradiction. $\square$. Let $r$ be an odd prime dividing $a^b b^a - 1$ that is not $1\pmod q$. We have $r$ divides $a^{2q} - b^{2q}$, so $\left( \frac ab \right)^{2q} \equiv 1\pmod r$. Hence the order of $\frac ab$ modulo $r$ divides $2q$. However, it can't be a multiple of $q$ as $q$ doesn't divide $r - 1$. Hence the order of $\frac ab$ modulo $r$ is either $1$ or $2$. If the order of $\frac ab$ modulo $r$ is $2$, then $r\mid a^2 - b^2 = (a-b)(a+b)$. But $\frac ab \not \equiv 1\pmod r$, so $r$ divides $a + b = 2p$, meaning that $r = p$. We have $a \equiv q\pmod p$ and $b\equiv -q\pmod p$, and both $a,b$ are even, so $a^b b^a \equiv q^b \cdot q^a \equiv q^{2p} \pmod p$, so $q^{2p} \equiv 1\pmod p$. But $q^p \equiv q\pmod p$, so $q^{2p} \equiv q^2 \pmod p$, meaning that $q \in \{-1,1\}\pmod p$. Since $q < p$, this means $q = p - 1$, which is absurd since $ q > 2$. Therefore, the order of $\frac ab$ modulo $r$ must be $1$. Then $r \mid a - b$, so $r = q$. Hence $a^b b^a \equiv 1\pmod q$. However, we have $a \equiv b \equiv p \pmod q$, so $p^{a+b} = p^{2p} \equiv 1 \pmod q$. If the order of $p$ modulo $q$ is $p$ or $2p$, we have a contradiction as $p$ cannot divide $q - 1$ (since $p > q$). Since the order of $p$ mod $q$ divides $2p$, it must be $1$ or $2$. Hence $p^2 \equiv 1\pmod q$, so $p\equiv \pm 1 \pmod q$. Since $q < p < 3q$, $p\in \{q+1, 2q-1, 2q+1, 3q-1\}$. By parity, $p$ can't be $q+1$ or $3q - 1$. If $p = 2q - 1$, then $a = 3q - 1$, $b = q - 1$, so $(3q - 1)^{q - 1} (q-1)^{3q - 1 } - 1$ divides $(3q - 1)^{2q} - (q-1)^{2q}$. Hence $(3q-1)^{q-1} \cdot (q-1)^{3q - 1} $ must be less than $(3q-1)^{2q}$, implying that $(q-1)^{3q - 1} < (3q - 1)^{q+1}$. However, we have\begin{align*} (3q - 1)^{q+1} < (3q - 3)^{q+1} = 3^{q+1} (q-1)^{q+1} \\ < (q-1)^{q+1} (q-1)^{q+1} = (q-1)^{2q+2} \\ < (q-1)^{3q - 1}, \\ \end{align*}absurd. Therefore, $p = 2q + 1$. But then $a = 2q + 1, b = q + 1$, so\[(3q + 1)^{q+1} (q+1)^{3q + 1} - 1 \mid (3q + 1)^{2q} - (q+1)^{2q}\]Hence $(q+1)^{3q + 1} (3q + 1)^{q+1} < (3q+1)^{2q}$, so $(q+1)^{3q + 1} < (3q + 1)^{q-1}$. But then\begin{align*} (3q+1)^{q-1} < (3q+3)^{q-1} = 3^{q-1} (q+1)^{q-1} \\ < (q + 1)^{2q - 2} < (q+1)^{3q + 1}, \\ \end{align*}absurd. Case 2: $q \le 3$. If $q = 2$, then $p < 3 \cdot 2 = 6$, so $p = 3$ or $ p =5$. To see $p = 5$ does not work, notice it implies $a = 7$ and $b = 3$, and $7^3 \cdot 3^7 - 1$ clearly does not divide $7^4 - 3^4$ (in fact it is much larger). Hence $p = 3$. If $q = 3$, then $5 < p < 3\cdot 3 = 9$, so $p \in \{5,7\}$. If $p = 5$, then $a = 8, b = 2$, but $8^2 \cdot 2^8 - 1$ doesn't divide $8^6 - 2^6$ (this can be proven by dividing the RHS by $2^6$ and getting a size contradiction). If $p = 7$, then $a = 10, b =4$, but $10^4 \cdot 4^{10} $ doesn't divide $10^6 - 4^6$ (since $10^4 \cdot 4^10 > 10^6$). Hence $q = 3$ is not possible. Therefore, we must have $p = 3, q = 2$, so we are done.