I know that
$$\tag{*}\boxed{\text{If }\gcd(a,n)=1, \text{then }a^{\varphi(n)}\equiv1\pmod{n}}$$
Also, more generally,
$$\tag{**}\boxed{\text{If }\gcd(a,c)=1, \text{then }a^b\pmod{c}\text{ reduces to }a^{b\pmod{\varphi(c)}}\pmod{c}}$$
I am sure about $(*)$, but not sure about $(**)$.
Here are some examples of $(**)$:
$6^{987}\pmod{35}$ reduces to $6^{987\pmod{24}}\pmod{35}$ which is $6^3\pmod{35}$ which is $216\pmod{35}$ which is $6$
Lets say $(**)$ is correct, then $6^{987}\equiv6\pmod{35}$ is correct.
I was trying to solve this question by $(**)$.
$17^{198}\pmod{100} \implies(**)\implies17^{198\pmod{\varphi(100)}}\pmod{100}\implies17^{198\pmod{40}}\pmod{100}$
$\implies 17^{38}\pmod{100}$
But I stuck what to do next since the exponent is already less than $\varphi(\text{divisor})$
How can I continue, effectively fast, from this step (without Carmichael function) and (with avoiding the use of negative integers)?
I am not pointing to that specific problem, but I am asking about an effective way when the exponent is already less than the phi value.
Your help would be appreciated. Thanks