4
$\begingroup$

Had a student tell me that the last digit of $9^{52}$ is $1$ (which it indeed is) since the last digit of $52$ is $2$ and the last digit of $9^2$ is $1$. Which raised the general question: when is $a^b\equiv a^{(b\bmod n)}\mod n$?

If $\gcd(a,n)=1$, then this is equivalent to $a^{b-(b\bmod n)}\equiv 1\mod n$, which is true only if the order of $a$ divides $b-(b\bmod n)$. (Since the order of $9$ working mod $10$ is $2$, and $2$ will always divide $b-(b\bmod 10)$, my student's trick will work for any power of $9$.) Not sure if this is really all that helpful, in practice, since the order of $a$ may be very computationally difficult to find. An interesting theoretical result would be nice, too, but I'm not sure if we can say anything more than I already have.

I think perhaps things get more interesting if $\gcd(a,n)\neq1$, but this is not my area of expertise. Any expert advice would be appreciated!

$\endgroup$
8
  • 4
    $\begingroup$ This is not quite the same as your question, but it may be of interest: for fixed $n$, we have $a^b \equiv a^{b \bmod n}$ mod $n$ for all $a$ coprime to $n$ if and only if the Carmichael lambda function $\lambda(n) \mid n$. See oeis.org/A124240. $\endgroup$ Commented Apr 29 at 18:26
  • $\begingroup$ Does this help? math.stackexchange.com/questions/2033639/… $\endgroup$ Commented Apr 29 at 18:37
  • 1
    $\begingroup$ Tweak this theorem. $\ \ $ $\endgroup$ Commented Apr 29 at 18:58
  • $\begingroup$ Funny: By that exponent "$b \pmod{n}$", you probably mean the representative in $\{0, 1, \dots, n-1\}$; but if one proves that, one also proves that the choice of representatives does not matter, by transitivity of congruence. $\endgroup$ Commented Apr 29 at 20:09
  • 2
    $\begingroup$ Oops. I see you already knew the statement was false. Sorry. $\endgroup$ Commented Apr 29 at 20:17

1 Answer 1

2
$\begingroup$

Here's a somewhat clunky characterization that deals with the $\gcd(a, n) \ne 1$ case. I think you can probably say nicer things if you only want a sufficient condition.

Let $a, n$ not necessarily coprime and $b$ be arbitrary. For convenience, write $b = qn + r$ with $0 \le r < n$, so that the condition $a^b \equiv a^{b \bmod n} \pmod{n}$ is equivalent to $a^{qn+r} \equiv a^r \pmod{n}$. Let $n = p_1^{k_1} \cdots p_s^{k_s}$ be the prime factorization of $n$. By the Chinese remainder theorem, the desired congruence then holds if and only if $a^{qn+r} \equiv a^r \pmod{p_i^{k_i}}$ for all primes $p_i \mid n$.

Now fix a prime $p \mid n$, and consider when $$ a^{qn+r} \equiv a^r \pmod{p^k} $$ holds. First, if $\gcd(a, p) = 1$, then by the same argument as in the OP, the congruence holds iff $\mathrm{ord}_{p^k}(a) \mid q n$. Otherwise, if $\gcd(a, p) \ne 1$, then we have $p \mid a$. Notice that the displayed congruence is equivalent to $a^{qn+r} - a^r \equiv 0 \pmod{p^k}$, or $p^k \mid a^r(a^{qn} - 1)$. Since $p \mid a$, we see that $p \nmid a^{qn} - 1$ unless $q = 0$, i.e., unless $b < n$. Hence $p^k \mid a^r(a^{qn} - 1)$ if and only if either $p^k \mid a^r$ or $b < n$ in this case.

This proves

Theorem. Assume $b \ge n$ so that the desired congruence is nontrivial. Then $a^b \equiv a^{b \bmod n} \pmod{n}$ if and only if, for all primes $p \mid n$ with multiplicity $k$, either

  • $p \nmid a$ and $\mathrm{ord}_{p^k}(a) \mid (b - b \bmod n)$, or
  • $p \mid a$ and $p^k \mid a^{b \bmod n}$.

which can be rephrased as

Corollary. Assume $b \ge n$ so that the desired congruence is nontrivial. Then $a^b \equiv a^{b \bmod n} \pmod{n}$ if and only if $\mathrm{ord}_m(a) \mid (b - b \bmod n)$ and $\frac{n}{m} \mid a^{b \bmod n}$, where $m$ is the product of the prime powers in $n$ coprime to $a$.

Note that in the case where $a$ and $n$ are coprime, this characterization reduces to the one stated in the OP, so in some sense it is a natural generalization.

$\endgroup$
1
  • 2
    $\begingroup$ Thanks, Joe. This is a bit clunky, but I'm not sure one can do any better. It seems for fixed a,b, and n, the best thing to do is to reduce both sides mod n and see if they're equal, lol! $\endgroup$ Commented Apr 30 at 13:07

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.