7 ms·
The sequence 2^n mod 3 goes 2, 1, 2, 1, 2... That's how you solve all problems of this form. For any a and b, a^n mod b eventually becomes periodic as n grows.
by cousin_it 11y ago
The sequence 2^n mod 3 goes 2, 1, 2, 1, 2...
That's how you solve all problems of this form. For any a and b, a^n mod b eventually becomes periodic as n grows. It's easy to prove because there's only a finite number of possible remainders mod b. As an exercise, calculate 3^1000000 mod 7.