If you need $x^p\mod{n}$ and $\gcd(x,n)=1\Rightarrow\exists i\in\{1,2,\dots,n-1\}$ such that $x^i\equiv1\mod{n}$.
By Fermat's Little Theorem $x^{n-1}\equiv1\mod{n}$. Maybe there exists $i
Then $(x^i)^m\equiv1^m\mod{n}\Rightarrow (x^i)^m\equiv1\mod{n}$.
Also $\exists q,r\in\mathbb{Z}:p=iq+r,~0\le r
If $\gcd(x,n)\ne1$ then $x^n\equiv x\mod{n}$ by Fermat's Little Theorem.
Also $\exists k_1,r_1\in\mathbb{Z}:p=k_1n+r_1,~0\le r_1
Let's do this:
(1) $x^{k_1n+r_1}=(x^n)^{k_1}\cdot x^{r_1}\Rightarrow x^{p}\equiv x^{k_1}\cdot x^{r_1}\equiv x^{k_1+r_1}\mod{n}$.
(2) If $k_1+r_1\ge n$ then go to (3) else go to (4).
(3) $\exists k_2,r_2\in\mathbb{Z}:k_1+r_1=k_2n+r_2,~0\le r_2
$~~~~~~~$Repeat step (1) but now with $k_2$ instead $k_1$ and $r_2$ instead $r_1$.
(4) We have $0\le k_i+r_i
For this case, we have to calculate $5^{10000}\mod{52}$.
$\gcd(5,52)=1\Rightarrow\exists i\in\{1,2,\dots,51\}:5^i\equiv1\mod{52}$.
Let's take $i=51$ by Fermat's Little Theorem, then $5^{51}\equiv1\mod{52}$.
$10000=196\cdot51+4$
$5^{10000}=5^{196\cdot51+4}=\left(5^{51}\right)^{196}\cdot5^4\Rightarrow5^{10000}\equiv\left(5^{51}\right)^{196}\cdot5^4\equiv5^4\equiv625\equiv1\mod{52}$.