View Single Post
Old 2020-03-18, 15:04   #47
retina
Undefined
 
retina's Avatar
 
"The unspeakable one"
Jun 2006
My evil lair

22×23×61 Posts
Default

In the spirit of this thread I also want to write an HLL version of the the LL test. Why not? Following is some awesome python code. And as a bonus it also does a PRP test.
Code:
for p in range(3, 1280, 2):
 mp, s = pow(2, p) - 1, 4
 for i in range(2, p): s = (s * s - 2) % mp
 if s == 0: print("2^{}-1 is prime".format(p))
 if pow(3, mp + 1, mp) == 9: print("2^{}-1 is PRP".format(p))
Can some help me to optimise it? I need it to run really really fast.
retina is offline   Reply With Quote