I created a program to calculate primes with mill's constant, but anyway, it results in huge computations being done. For instance, 1.306... ** 5661
It throws an overflow error. How can I fix this? I tried xrange, and it failed to help me because that no longer exists in python 3. I don't know how to reduce it.
Can anyone give me some help? Thanks a lot!
Edit: here's the code:
theta = 1.3063778838630806904686144926026
bottom = int(input("lower bound: "))
top = int(input("high bound: "))
for i in range(0,top + 1):
print(round(theta ** (3**i))) # causes the error
rangein Python 3 behaves like Python 2'sxrange. But that's not your problem. The numbers produced by Mill's formula rapidly become enormous, far too big to fit in a float. You could use thedecimalmodule instead, to get a few more values before you run out of RAM. Another option is to do the calculation using rational numbers: express Mill's constant as a fraction, and use//floor division to divide the numerator by the denominator, which will give you integer answers.