0

For a number $a^{x^{...^n}} $. To find its last digit in a base b,

Imagine that I have this number $a^{x^{y}}$ to simplify the problem. Then I calculate $a^{x} \equiv c \pmod b$ and after that $c^{y} \equiv d \pmod b$ which means that d is the last digit. Am i right?

Thanks !

Eric Wofsey
  • 330,363
Moh18
  • 101

1 Answers1

1

The procedure you suggest does not work since the conventional meaning of $a^{x^{y}}$ is that it means $a^{(x^{y})}$ whereas you were finding $(a^x)^{y}$.

Depending on the problem you wish to solve, it is likely that the best method for you would be to find a power $N$ of $a$ which is 1 modulo $b$ and then consider $x^y$ modulo $N$.

  • $2^{(2^{3})}=256$ whereas $(2^2)^{3}=64$. They do not have the same last digit in base 10 –  Oct 27 '19 at 14:28
  • As I said it depends on the problem - it is usually the best method –  Oct 27 '19 at 14:49
  • what would be a method that would work in all cases? Would Euler's Theorem be useful? So according to Euler's theorem, if $a$ and $b$ are coprime, there will always be an $N=\varphi(b)$ such that $a^N\equiv 1\pmod b.$ So we have $x^y \equiv b \pmod N\Leftrightarrow a^{x^y}\equiv a^b\pmod N.$ – Simon Fraser Oct 27 '19 at 14:59
  • @S. Dolan It's $x^y \equiv c \pmod b$ first and $a^c \equiv \pmod b$. As Simon Fraser said, is there a general mmethod ? – Moh18 Oct 27 '19 at 15:05
  • it's $x^y\equiv c\bmod N \implies a^{x^y}\equiv a^c\bmod b$ –  Oct 27 '19 at 15:13
  • @Moh18, as I mentioned in my above comment, you can use Euler's Theorem if $a$ and $b$ are coprime. If not, then there are two cases: 1) $a$ and $b$ have the same prime factors. In that case, there exists an $N$ such that $a^N\equiv 0\pmod b.$ This $N$ is simply the least common multiple of all the powers of the prime factors of $b.$ This is easy to prove. 2) $a$ and $b$ do not have the same prime factors. Then – Simon Fraser Oct 27 '19 at 15:14
  • correction: I should've written $x^y \equiv c\pmod N \Leftrightarrow a^{x^y}\equiv a^c\pmod b$ – Simon Fraser Oct 27 '19 at 15:19
  • Also @Moh18 it is very easy to find the last digit of a power. It's the same as the last digit of its units digit raised to the same power. So you just need to find the period of the units digit and take the exponent $x^y$ modulo this period. –  Oct 27 '19 at 15:31