Q:

Why is $5^{25} \equiv 22 \mod 193$

I'm trying to apply the square and multiply algorithm and I'm getting strange results even though I'm pretty sure I've done everything right. I'm trying to calculate $5^{25} \mod 193$:
Binary representation of 25: 11001
\begin{equation}
\begin{split}
5^2 = 25 \\
25*5 = 125 \\
125^2 = 185 \\
185*5 = 153 \\
152^2 = 56 \\
56^2 = 48 \\
48^2 = 181 \\
181*5 = 133
\end{split}
\end{equation}
But when I check my answer on wolframalpha it tells me the correct solution should be 22. I checked every single step twice. What did I miss?

A:

Looks to me like you're computing $5^{57}$.

start with $5^2$
multiplying that by $5$ gives $5^3$
squaring that gives $5^6$
multiplying that by $5$ gives $5^7$
squaring that gives $5^{14}$
squaring that gives $5^{28}$
squaring that gives $5^{56}$
multiplying that by $5$ gives $5^{57}$

