Hi Diogo. :>) You are so close. A favorite subject of mine. You may
find this of interest.
For your stated problem, your large first number is written in the form of
When an intermediate number is large (ie 10^32), there is a Number Theory
procedure that is much more efficient by avoiding such a large calculation.
Problems of the form Mod(n^m,x) are usually not calculated like this
directly, but are usually calculated by a function that usually goes by the
If you do an internet search, you should be able to find a number of
To give you some idea, the following calculation would be hard.
81703395 ^ 81703395
It has over 646,000,000 digits in the answer.
Given that, who knows how astronomically large the first number is here:
Mod(123456789012345678901234567 ^ 123456789012345678901234567, 97)
However, Excel can calculate this easily and quickly.
(Mine has been modified to do these types of calculations.)
given that n = 123456789012345678901234567
?PowerMod(n, n, 97)
So, given that, these are easy.
Debug.Print PowerMod(10, 29, 97)
Debug.Print PowerMod(10, 33, 97)
Debug.Print PowerMod(10, 999, 97)