Let $f(n) = n^n\:[100]$ be the euclidean remainder of $n$ to the power of itself divided by 100, also known as the last two digits in decimal notation.
$n^n$ is a big number and time-consuming to compute.
Is it true that f is 100-periodic?
The following Python implementation provides two algorithms to compute the last two digits: a naive one and a recursive algorithm using multiplication rules. The goal is also to potentially improve the algorithm.
https://pyfiddle.io/fiddle/1456a98a-f771-475c-8eb1-610667588279
From running the simulation it looks like it follows the same pattern every 100. I also observed that :
$(n+100)^{n+100} = \sum\limits_{k=0}^{n+100} \binom{n+100}{k}n^{n+100-k}100^k = n^{n+100}\:[100] $
$100 = 2^2 5^2$ from the prime decomposition
$n^2 = n [2]$ and $n^5 = n [5]$ from Fermat's little theorem.
$n^{100} = (n+2i)^2(n+5j)^2 = n^4 + 10n^3j + 25n^2j^2 + 4n^3i + 40 n^2ij + 40 n^2i^2 + 40ni^2j\:[100]$ from expanding the terms.
Prove that $\forall n \in \mathbb{N}$, $(n+100)^{n+100} = n^n\:[100]$ or give a counter example.
Bonus question: What it the smallest period of $f$?
If so, $n^{100} = n^{20 \times 5} = 1:[100]$. Meaning that if 2 or 5 doesn't divide $n$ we get a recursive algorithm by first computing $k=n:[20]$, $m=n:[100]$ and then applying another algorithm that works fine for $m^k<n^n$, instead. So the problem reduces to studying the cases $m<100$, $k<20$.
– Michel Hua Apr 12 '18 at 15:16$(i>0, j>0)$ We can at least observe that if 10 divides $n$, $n^n = 0 [100]$ proving the periodicity by absorbing multiplicity of the binomial formula above $f(n+100)=f(n)=0$.
$(i=0, j>0), n=5^j$ If 5 divides $n$, we observe that if $n$ finishes by 5 than $f(n)$ always equals 25. See last expansion from Fermat little theorem.
– Michel Hua Apr 12 '18 at 16:15