How would I evaluate this?

19 ^ 99 mod 160

The usual method using Euler's Theorem doesn't seem to help.

Is there another strategy I should learn about?

#maths #numbertheory

@rzeta0 Can you not just compute it piecemeal? So eg work out 19^3 mod 160, cube the result to give you 19^9, and so on. Because you can keep taking the result modulo 160, the numbers never get too big.

@kbm0

I have to think about this - it seems like a simple method.

Why didn't I think of it? Is it because my brain has become stuck in the methods taught by the textbook I'm following and not seeing beyond those.

@kbm0

I've done that thinking and this is a great approach

thank you!

@kbm0 @rzeta0 Also, IIRC, you can use the https://en.wikipedia.org/wiki/Chinese_remainder_theorem to keep the numbers slightly smaller my calculating modulo 32 and 5 and then reconstructing.

You'd get that 19^99 is 4 mod 5 and 19^99 is 11 mod 32, and apply one of the computation techniques from the linked article.

Chinese remainder theorem - Wikipedia

Search starting from 19^99 = 11 mod 32

11 /= 4 mod 5
43 /= 4 mod 5
75 /= 4 mod 5
107 /= 4 mod 5
139 = 4 mod 5

-> 19^99 = 139 mod 160

@BoydStephenSmithJr

thank you - the textbook author's official solution uses the Chinese remainder theorem but it has always been something my brain didn't like

this is a good opportunity to revisit it

thanks again for your help

@BoydStephenSmithJr @kbm0

here is my ugly write-up of that particular exercise

https://numbertheorystepbystep.blogspot.com/2026/04/exercise-5219.html

(I've been trying to write up every exercise in the book I'm working through, it helps me learn it all better)

Exercise (5.2).19

Determine the last three digits of $$ 2019^{2019^{2019}} $$ [Tower rule $a^{m^n}= a^{(m^n)}$.] Lemma We first prove a useful lemma. For natu...

@rzeta0

ghci> 19^99 `mod` 160
139

(The other poster's idea of doing the multiplications mod 160 is also correct.)