# Find all primes $p,q$ and even $n > 2$ such that $p^n+p^{n-1}+\cdots+1 = q^2+q+1$

Find all primes $p,q$ and even $n > 2$ such that $p^n+p^{n-1}+\cdots+1 = q^2+q+1$.

Attempt

The first thing I would do is simplify the geometric series to $\dfrac{p^{n+1}-1}{p-1} = q^2+q+1$. I was thinking from here we could use a modular arithmetic argument, perhaps using FLT. It is unclear to me though how to proceed since we are working with two different primes.

• To start you could try to write the equation as $p(p^{n}-1) = (p-1)q(q+1)$ and use that $p,q$ are prime to deduce that if $p\not=q$ then $p\mid q+1$ and $q\mid p^n-1$. – Winther Feb 12 '16 at 5:05
• artofproblemsolving.com/community/c6h29570p182765 – user236182 Feb 12 '16 at 9:05

Subtracting $1$ from both sides and factoring yields $$p(p^{n-1}+p^{n-2}+\dotsb+1)=q(q+1).$$ Since $p$ and $q$ are primes, this leads to certain conclusions. Is that enough to go on?

• If you don't have a full solution in mind, then you should've posted this as a comment. Immediately I can see that $p\mid q+1$ and $q\mid p^{n-1}+p^{n-2}+\cdots+1=(p+1)\left(p^{n-2}+p^{n-4}+\cdots+1\right)$. If $q\mid p+1$, then no solutions, so $q\mid p^{n-2}+p^{n-4}+\cdots+1=\frac{p^n-1}{(p+1)(p-1)}$, so $q\mid p^n-1$. – user236182 Feb 12 '16 at 9:31
• @user236182 That's ridiculous. People are allowed to post hints on this website. It's up to the asker to fill in the blanks, unless other people (such as yourself) do it for them. – Dustan Levenstein Feb 12 '16 at 14:52
• @kierenmacmillan I meant "in mind". If you don't know how to solve the problem, then you shouldn't post an answer. People only post "hints" when they know how they could lead to a full solution. There are exceptions when people say "here is some progress:" in their answers to difficult questions. – user236182 Feb 12 '16 at 19:06
• I was assuming you don't know how to solve the problem. From the approaches I've seen (see also the link in the comments), the problem doesn't seem simple enough for this to be a decent hint - more like a comment. Tell me if I'm wrong. – user236182 Feb 12 '16 at 19:18
• @DustanLevenstein – user236182 Feb 12 '16 at 19:19

The solutions can be found deriving a bounding condition on $p$ and $n$. Here's another approach:

Manipulate the equation into $$p\left(p^{n-1}+p^{n-2}+\cdots+1\right)=p\frac{p^n-1}{p-1}=q(q+1) \tag{\star}$$ to see there must exist an integer $a>1$ (since $n>2$) such that $$q+1=ap \tag{1}$$and $$\frac{p^n-1}{p-1}=aq. \tag{2}$$ Subtract $1$ from both sides of $(2)$ to get $$\frac{p^n-p}{p-1}=p\frac{p^{n-1}-1}{p-1}=aq-1,$$ and summing this to $(1)$ we arrive at $$p\left(a+\frac{p^{n-1}-1}{p-1}\right)=q(a+1),$$ whence $a=bp-1$ for some $b\in\mathbb{N^+}$. Substituting into $(\star)$ we finally obtain \begin{align}\sum_{k=0}^{n-1}p^k=(bp-1)(p(bp-1)-1)&=(bp-1)(bp^2-p-1) \\ &=b^2p^3-2bp^2-(b-1)p+1\end{align} and thus \begin{align}\sum_{k=0}^{n-2}p^k=b^2p^2-2bp-b+1 \end{align} $$\sum_{k=1}^{n-2}p^k=b^2p^2-2bp-b, \tag{3}$$ which shows that $b$ is both a multiple and a divisor of $p$, i.e. $b=p$. Hence $(3)$ is equivalent to \begin{align}\sum_{k=0}^{n-3}p^k&=p^3-2p-1 \\p\left(p^2-2-\sum_{k=0}^{n-4}p^k\right)&=2,\end{align}wherefrom we conclude $(n,p,q)=(4,2,5).$

Suppose that $n=2k$ for some integer $k>1$. Then we have $q(q+1)=p\left(\frac{p^{2k}-1}{p-1}\right)$. As $k>1$, $p\neq q$, so that $q$ divides $p^{2k}-1=\left(p^k+1\right)\left(p^k-1\right)$. That is, $q$ divides either $p^k-1$ or $p^k+1$. In any case, $q\leq p^k+1$. Therefore, $$p^{2k}+p^{2k-1}+2< p^{2k}+p^{2k-1}+\ldots+p=q^2+q\leq \left(p^k+1\right)^2+\left(p^k+1\right)=p^{2k}+3p^k+2\,.$$ Ergo, $p^{2k-1}<3p^k$, or $p^{k-1}<3$. Consequently, $k=2$ and $p=2$. Hence, the only solution $(p,q,n)$ to $p^n+p^{n-1}+\ldots+p+1=q^2+q+1$ with $p,q,n\in\mathbb{N}$ such that $p$ and $q$ are primes and that $n>2$ is even is $(p,q,n)=(2,5,4)$.

In fact, if $n$ is allowed to be an odd integer greater than $2$, then it follows that $p=2$ (otherwise $p^n+p^{n-1}+\ldots+p+1$ is even, but $q^2+q+1$ is odd). That is, we are looking for a prime $q$ such that $q^2+q=2^{n+1}-2$, or $(2q+1)^2=2^{n+3}-7$. As $n$ is odd, $n+3$ is even. That is, $$\left(2^{\frac{n+3}{2}}-2q-1\right)\left(2^{\frac{n+3}{2}}+2q+1\right)=7\,.$$ Hence, $2^{\frac{n+3}{2}}-2q-1=1$ and $2^{\frac{n+3}{2}}+2q+1=7$. Consequently, $2^{\frac{n+3}{2}}\leq 6<2^3$. Thus, $n<3$, which is a contradiction.

In conclusion, the only solution $(p,q,n)\in\mathbb{N}^3$ to $p^n+p^{n-1}+\ldots+p+1=q^2+q+1$ with $p$ and $q$ being prime is $(p,q,n)=(2,5,4)$.