For how many integral value of $x\le{100}$ is $3^x-x^2$ divisible by $5$?

I compared $3^x$ and $x^2$ in $\mod {5}$ i found some cycles but didn't get anything

  • 2
    $\begingroup$ What do you mean by didn't get anything? I get twenty values $\{2,4,16,18,22,24,36,38,42,44,56,58,62,64,76,78,82,84,96,98\}$ $\endgroup$ Aug 22, 2014 at 10:03
  • $\begingroup$ @gammatester I know this all but this is a question of competitive exam where i have to solve question in 3 mins and no calculator is allowed so i was searching for a short method. $\endgroup$ Aug 22, 2014 at 15:33

2 Answers 2


HINT : For $n\in\mathbb N$,

$n$ can be divided by $5$ $\iff$ The right-most digit of $n$ is either $0$ or $5$.

You'll find some patterns in the followings from $x=1$ to $x=20$.

The right-most digit of $3^x$ : $3,9,7,1,3,9,7,1,3,9,7,1,3,9,7,1,3,9,7,1.$

The right-most digit of $x^2$ : $1,4,9,6,5,6,9,4,1,0,1,4,9,6,5,6,9,4,1,0.$


Here I will give a complete solution using congruences:
For any non negative integer $x,$ we can prove that $$3^{4m}≡1(mod10),$$ $$3^{4m+1}≡3(mod10),$$ $$3^{4m+2}≡9(mod10),$$ $$3^{4m+3}≡7(mod10).$$ Also for any (positive) integer $x,$ we have $$x^2≡0,1,4,5,6,9(mod10)$$ for $x≡0,\pm1,\pm2,\pm 3, \pm4, 5(mod10)$ respectively.
If $n=|3^x-x^2|$ is divisible by $5,$ Its last digit should be $0$ or $5.$ Therefore we have following few cases:

  • $x$ is of the form $4m$ and $10n\pm1.$ This is impossible.
  • $x$ is of the form $4m$ and $10n\pm4.$ So $x≡\pm4(mod20).$
  • $x$ is of the form $4m+2$ and $10n\pm2.$ Here, $x≡\pm2(mod20).$
  • $x$ is of the form $4m+2$ and $10n\pm3.$ This is again impossible.

Altogether we have $20$ possible integer solutions less than $100,$ namely $$\{2,4,16,18,22,24,36,38,42,44,56,58,62,64,76,78,82,84,96,98\}.$$


You must log in to answer this question.

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