Hi I have been trying to run this script using all of the cpu cores however it will only use one core and I can't find out why. Is there some initialization that tells it to use only one core or does python not use all cores? I thought about having it save the exponent it is on to a text file and having multiple instances of the program. It would then reopen the text file and check the next number. But it seems that multithreading this would be the fastest.
test = 1
one = 2281
i = 1
init = 1
f_open = open('PRIMEEXPONENT.txt', 'r')
data = f_open.read()
f_open.close()
print (data)
string3 = "%s" % (data)
def check(p):
s = 4
m = 2 ** p - 1
for _ in range(p - 2):
s = ((s * s) - 2) % m
return s == 0
def is_prime(number):
if number % 2 == 0:
return number == 2
i = 3
while i * i <= number:
if number % i == 0:
return False
i += 2
return True
print(3)
var2 = 1
while var2 == 1 :
i = i + 2
if init == 1:
print ("RELOADING PREVIOUS SAVED PRIME NUMBER")
i = int(data)
print ("DONE")
init = 0
if is_prime(i) and check(i):
print ("START NUMBER")
print(2 ** i - 1)
string = "%s" % (2 ** i - 1)
string2 = "%s" % (i)
string5 = "%s" % ("START ")
string6 = "%s" % ("END ")
string7 = "%s" % (" ")
print ("END NUMBER")
f = open("PRIME.txt", 'a')
f.write(string5)
f.write(string)
f.write(string6)
f.close()
f = open("PRIMEEXPONENT.txt", 'w')
f.write(string2)
f.close()
f = open("PRIMEEXPONENT2.txt", 'a')
f.write(string5)
f.write(string2)
f.write(string7)
f.write(string6)
f.close()