Answer the question
In order to leave comments, you need to log in
How to get rid of overflow in math module?
I solve a study problem.
I get an OverflowError: math range error.
from math import *
def get_b(p, a):
start_time = time.time()
# b = math.fmod(math.pow(a, p-2), p)
b = pow(a, p-2)
b = b % p
print("--- %s seconds ---" % (time.time() - start_time))
return int(b)
print(get_b(2097151, 9))
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question