Find all integers n such that $(\frac{n^3-1}{5})$ is prime?

My Approach:

I wrote all the prime which i will get after dividing $(n^3-1)$ by $5$.


which lead me to $n^3=11,16,26,...,216$, then I obtained $n=6$

My doubt is that how to check more value of $n$ without using modular arithmetic because the book I'm referring has not introduced it yet.

Second approach: $\frac{(n^3-1)}{5}=\frac{(n-1)(n^2+n+1)}{5}$

But my second approach too does not lead me anywhere.

This problem is from the book Pathfinder for Olympiad Mathematics

  • $\begingroup$ The factorization in your second approach is the key. One of $n-1$ or $n^2+n+1$ has to be divisible by five. Basic congruence stuff tells you which it is. Call it $A$ and the other $B$. Then you have two possibilities. Either $B$ is prime and $A/5=1$. Or $A/5$ is a prime and $B=1$. The rest is elementary. $\endgroup$ May 26, 2021 at 10:11

2 Answers 2


If we split all integer $n$ into $[5m+1,5m+2,5m+3,5m+4,5m+5]$ you can show that only numbers $(5m+1)^3-1$ are divisible by $5$ as $[2^3-1,3^3-1,4^3-1,5^3-1]$ are all not divisible by $5$

Now $$\frac{(5m+1)^3-1}{5}=3m+15m^2+25m^3=m(3+15m+25m^2)$$

and the product $m(3+15m+25m^2)$, can only be a candidate prime if $m=\pm1$

  • $\begingroup$ [+1]! Technically, you should also check the case when $3+15m+25m^2=\pm 1$. But it is easy to notice that this equations won't yield a integer solution :) $\endgroup$
    – Dr. Mathva
    May 29, 2021 at 11:39

First, since you need the fraction to be a prime, you have $n^3-1 = 5p$ with $p$ a prime number. Now, $n^3-1=(n-1)(n^2+n+1)$. So this leads to the idea that one of those factors is $5$ and the other $p$.

  • If $n-1=5$, $n=6$ so $n^2+n+1= 36+6+1= 43$.

  • If $n-1\neq 5$, $n^2+n+1=5$, so $n(n+1)=4$, and you can check in multiple ways that this equation doesn't have solutions. (one way is noticing the parity of the lhs and forcing the odd factor to be $1$, so the other won't reach to be $4$)

EDIT: As how mentioned @lhf , I'm missing if $n^3 - 1 = -5p$ So considering this case, you have these cases:

  • If $n-1 = -5$, $n = -4$, so $n^2+n+1 = 16 - 4 +1 = 13$

  • If $n-1 \neq -5$, then $n^2+n+1 = -5$, and this leaves to $n^2+n = -6$, obtaining with general formula this doesn't give any possible solution.


  • If $n-1 = -5p$, $n^2+n+1=1$, but this will mean $(5p)^2-5p=0$, implying $5p(5p-1)=0$, forcing $5p-1=0$, but that leaves $p$ not being a prime.

  • If $n-1 = 5p$, then $n = 5p + 1$, so $(5p+1)^2 + 5p + 1 +1 = 0$, giving $25p^2+15p + 3 = 0$, but this equation doesn't have any integer solution, since this would mean $5\mid 3$, which is a nonsense.

Then the solutions are $(n,p)$ are $(6,43), (-4,-13)$

  • 1
    $\begingroup$ There are also the cases $n-1=\pm1$ and $n-1=-5$, which gives $p=-13$. $\endgroup$
    – lhf
    May 26, 2021 at 10:29
  • $\begingroup$ but for $n=-4$ I obtained $\frac{n^3-1}{5}=-13$ which is not a prime. $\endgroup$
    – mathophile
    May 26, 2021 at 10:57
  • 1
    $\begingroup$ $-13$ is a prime. The definition I have of a prime number $p$ is a number that is divisible by $\pm 1$ and $\pm p$. If you're considering as a prime only the numbers such that are only divisible by $1$ and themselves, then you can consider $-13$ isn't a prime, but the definition I gave you is the one for primes. $\endgroup$
    – iam_agf
    May 26, 2021 at 11:01
  • $\begingroup$ Taking $n=4$ yields $5\nmid n^3-1$. I believe you meant $(6,43)$ $\endgroup$
    – Dr. Mathva
    May 29, 2021 at 12:14

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.