Divisibility of the difference between two very large numbers I am learning from chapter 1 of the algorithm textbook known as DPV.
There is a question 1.11 that asks:
Is $4^{1536} - 9^{4824}$ divisible by 35?
The whole chapter is on modular arithmetic, modular exponentiation, Euclid GCD (as far I got so far) so I broke down the first term to
$2^{3072}$ and second term to
$3^{2(2048)} * 3^{2(2048)} * 3^{3(512)} * 3^{2(128)} * 3^{3(64)} * 3^{3(16)} * 3^{3(8)}$ thinking it would lead to some sort of aha moment but the only conclusions I can draw is that the first term's factors are all divisible by 2, the second term's are all divisible by 3 and 35 has factors 5 and 7 so neither is divisible by 35 on its own.  How can I apply any of the modular arithmetic or Euclid's GCD to this problem to solve it?
 A: Note that if $4^{1536}\equiv 9^{4824} \bmod 35$ then $35$ divides $4^{1536}- 9^{4824}$, otherwise not.
There are various tools that could help you decide this, and if you have heard of Euler's theorem and the Chinese remainder theorem these could certainly help, but with just the idea of modular exponentiation you can investigate the powers of $4$ and $9$ $\bmod 35$ and reach a conclusion.
Successive powers of $4\bmod 35$ look like:
$4^1 \equiv \color{blue}{4},
4^2\equiv \color{blue}{16},
4^3\equiv 64\equiv \color{blue}{29}, 
4^4\equiv 116\equiv \color{blue}{11}, 
4^5\equiv 44\equiv \color{blue}{9}, 
4^6\equiv 36\equiv \color{red}{1}$
Successive powers of $9\bmod 35$ look like:
$9^1 \equiv \color{blue}{9},
9^2\equiv 81\equiv \color{blue}{11},
9^3\equiv 99\equiv \color{blue}{29}
9^4\equiv 261\equiv \color{blue}{16}, 
9^5\equiv 144\equiv \color{blue}{4}, 
9^6\equiv 36\equiv \color{red}{1}$
(If you know about modular inverse, you can also see from the powers of $4$ that $4^{-1}\equiv 9 \bmod 35$ which is why the two power value sequences are mirror images of each other.)
And then casting out multiples of $6$ in the exponent allows us to finish the calculations without difficulty; for example $4^{23} = 4^{3\cdot\color{red}{6}+\color{blue}{5}}\equiv \color{red}{1}^3\cdot 4^{\color{blue}{5}}\equiv \color{red}{1}\cdot \color{blue}{9}\equiv 9\bmod 35$.
