I'm sorry before if this suspected to be duplicate question.

The problem is :

How many pairs of positive integer $(p,q)$ which satisfy $(p+1)!+(q+1)!=p^{2}q^{2}$

I tried to expand the factorial but i can't continue , I've put it on wolframalpha but i dont get any step by step solution there. Is there any kind of theorem or somehting would help me to solve this?


3 Answers 3



factorials grow much faster than squares.

Without loss of generality you can assume $p\geq q$. (edit: If $q>p$, you can just interchange $q$ and $p$ and then you have $p \geq q$. Of course you need to consider this at the end, when you count the number of possible solutions $(p,q)$. )

For large $p$ the left-hand side will be much larger than the right-hand side. Can you find a bound on $p$ for that?

After that, you only have to check finitely many values for $p,q$.

  • $\begingroup$ thank you first, but how could we assume that $p \geq q$ ? and then actually i don't know how to find a bound for $p$. $\endgroup$
    – SutMar
    Commented Jun 28, 2017 at 10:38
  • $\begingroup$ addition, i know the fact that factorial grow faster than exponential. $\endgroup$
    – SutMar
    Commented Jun 28, 2017 at 10:46
  • $\begingroup$ The equation is symmetric so you can always sort them so that $p$ is larger. And because the left side grows faster, you can simply brute force it: increase $p$, for each $p$ try every $q$ smaller than $p$ until it fails, and then stop at $p$ where it goes over even for the smallest $q$. $\endgroup$
    – orion
    Commented Jun 28, 2017 at 11:22
  • $\begingroup$ @SutMar edited to reflect your question $\endgroup$
    – supinf
    Commented Jun 28, 2017 at 11:35

If you don't need to solve this analytically, I'd say you can just solve this by trying out: Choose $q=1,2,3,4,...$ and calculate both sides for a growing $p$ till the left-hand side is bigger than the right-hand side. As mentioned before the factorial is growing way faster so if the right-hand side is already bigger, there won't by any further solutions for the equation.

  • $\begingroup$ that was my alternative way and i really want to see it analytically. by the way that was my quiz on college,lecturer gave us within 10 minutes to solve this. $\endgroup$
    – SutMar
    Commented Jun 28, 2017 at 11:54

$p = 1, q = 1$ or $p = 1, q = 2$ or $p = 2, q = 1$ have no solution.

$p$ and $q$ both cannot be odd.

Assume $p \ge 2$ and $q \ge 2$ and assume both $p,q$ even

Let $p = 2^m p_1$ where $p_1$ is odd and $q = 2^n q_1$ where $q_1$ is odd

$(p+1)! = (2^mp_1 + 1)! = (2^mp_1 +1)(2^mp_1!) = 2^a x$, where $a = 2^m -1$, and $x$ is odd

$(q+1)! = (2^nq_1 + 1)! = (2^nq_1 +1)(2^nq_1!) = 2^b y$, where $b = 2^n -1$, and $y$ is odd

So $2^ax + 2^by = 2^{2m+2n}p_1^2 q_1^2$

If $a > b$, then $2^b(2^{a-b}x + y) = 2^{2m+2n}p_1^2 q_1^2$

For a solution to exist, we need $b = 2m + 2n \implies 2^n - 1 = 2m + 2n$ not possible as odd and even

If $a = b$ implies one of $p,q$ is odd and other is even, a case we consider next.

So let us consider the case where $p$ is even, $q$ is odd.

Let $p = 2^m p_1$ where $p_1$ is odd and $q+1 = 2^n q_1$ where $q_1$ is odd

$(p+1)! = (2^mp_1 + 1)! = (2^mp_1 +1)(2^mp_1!) = 2^a x$, where $a = 2^m -1$, and $x$ is odd

$(q+1)! = (2^nq_1)! = 2^b y$, where $b = 2^n -1$, and $y$ is odd

So $2^ax + 2^by = 2^{2m} p_1^2 q^2$

If $a > b$, then $2^b(2^{a-b}x + y) = 2^{2m}p_1^2 q^2 \implies b = 2m$ not possible as b is odd.

If $a = b$ then $2^b(x+y) = 2^{2m}p_1^2 q^2$. Let highest power of $2$ in (x+y) be c.

So we need $2^{b+c} = 2^{2m} \implies b+c = 2m \implies 2^m -1 + c = 2m$.

For $c=1$, we get $2^m = 2m \implies 2^{m-1} = m \implies m = 2 \implies p = 4$.

This implies $q = 3$ as $a = b$ implies $p$ and $q$ differ by $1$.

For all other $c$ there is no solution.

So only solution is $4,3$.

  • $\begingroup$ $(3+1)!+(4+1)!=3^2\cdot4^2$. $\endgroup$
    – jpvee
    Commented Jun 28, 2017 at 21:56
  • $\begingroup$ agreed. thanks. I didnt analyze the case of $a = b$ properly. [$2^a $ and $2^b$ are the purely even factors of $(p+1)!$ and $(q+1)!$ respectively] $\endgroup$
    – sku
    Commented Jun 29, 2017 at 3:32

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .