Find all prime numbers $p$ and $q$ such that $pq-p-q+3$ is a perfect square.
Problem
Source: Kosovo Mathematical Olympiad 2022, Grade 9, Problem 4
Tags: number theory, prime numbers
06.03.2022 17:22
We have $pq-p-q+3=pq-p-q+1+2=(p-1)(q-1)+2$. Case 1: $p$ and $q$ are odd. If either one is $1\pmod 4$, then $(p-1)(q-1)+2\equiv 2\pmod 4$, and thus not a perfect square. The same result holds when both are $3\pmod 4$. So there are no solutions for this case. Case 2: At least one of $p,q$ is $2$. Clearly $p=q=2$ doesn't work. If $p=2$, then $q+1$ is a perfect square. If $q+1=k^2$, then $q=k^2-1=(k-1)(k+1)$, so $k-1=1\implies k=2\implies q=3$. Similarly if $q=2$, then $q=3$. Thus, our solutions are $\boxed{(2,3)}$ and $\boxed{(3,2)}$, which work.
28.04.2023 00:25
Case 1: $p=q=2 \Rightarrow pq-p-q+3=3$, which is not a perfect square Case 2: $p,q$ are odd $\Rightarrow pq-p-q+3=(p-1)(q-1)+2 \equiv 2 \pmod{4}$, which is not a perfect square Case 3: $p=2 \Rightarrow q+1=x^2 \Rightarrow q=x^2-1=(x-1)(x+1) \Rightarrow x-1=1 \Rightarrow x=2 \Rightarrow q=3$ Therefore, $(p,q)=(2,3),(3,2)$ are the only solutions $\blacksquare$
05.05.2023 18:43
By SFT, we can simplify this to $(p-1)(q-1)+2$. Let us know do cases based on the parity of $p$ and $q$. $\mathbb{\text{Case 1:}}$ Let us first say that $p$ and $q$ are odd primes, getting that both $p-1$ and $q-1$ are even. If we then take this modulo $4$, we get: \[0+2\equiv 2\pmod{4}.\] However, if this is a perfect square, it can only be $0,1\pmod{4}$ meaning that this case does not work. $\mathbb{\text{Case 2:}}$ Let us say that one of $p$ and $q$ is odd and the other one is $2$. WLOG, let us say that this is $p$, so we can simpliy the expression to $q+1$. If we say that this is $a^2$ for any positive integer $a$, we get: \[q=(a-1)(a+1).\] Since $q$ is prime, $a-1=1$ meaning that $q=3$. However, we can switch it around and say that $p=3$ and $q=2$. $\mathbb{\text{Case 3:}}$ Now let us say that both $p$ and $q$ are $2$. Then we get the expression as $3$ which is not a perfect square. Thus, the only ordered pairs of $(p,q)$ are $(3,2)$ and $(2,3)$.