this question is different from [Exponentials in python x.**y vs math.pow(x, y) because a snippet using math.pow() cannot compute result, while the ** operator can.
I am experimenting with a little snippet to compute first N doubly prime numbers with Fermat's Little theorem:
per 1<= a < n
,
if a^n mod(n) = a mod(n)
then n is a Prime
http://en.wikipedia.org/wiki/Fermat%27s_little_theorem http://en.wikipedia.org/wiki/Fermat_pseudoprime
I found that:
math.pow(a,n) % n == a % n
yields to overflow error:
math range error
for: a = 2
, n == 1508950
instead with **
operator works fine:
2**1508950
yields ... a very, very, very long number :)
2**1508950 = 1629135338929954... #with 450K+ and counting digits.
Python documentation states that The two-argument form pow(x, y) is equivalent to using the power operator: x**y
.
Why this difference ?