How to calculate $n\bmod p$ when $p$ is prime, and $n$ is an integer of form $a9999...$ where $a$ is digit $1$ to $9$. The number of digits $9$ that follow $a$ is huge (i.e. big enough to not fit memory of my PC).
Asked
Active
Viewed 23 times
0
-
Since $10^p\equiv 10\pmod{p}$, you can reduce it to more than $p+1$ digits. – Arturo Magidin Apr 03 '21 at 21:49
-
By mod order reduction $\bmod p!:\ 10^{p-1}\equiv 1\Rightarrow (a!+!1)10^k!-!1\equiv (a!+!1)10^r!-!1,$ for $,r = k\bmod{!p!-!1},,$ for $,p\neq 2,5\ \ $ – Bill Dubuque Apr 03 '21 at 22:01