p = 2
for i in range(3,10000000000000000,2):
if p%i >= 1:
print(i)
p = p*(i*i)
I've tested it and it seems to work on at least the first 100 primes, will it accurately return primes indefinitely?(theoretically not literally).
p = 2
for i in range(3,10000000000000000,2):
if p%i >= 1:
print(i)
p = p*(i*i)
I've tested it and it seems to work on at least the first 100 primes, will it accurately return primes indefinitely?(theoretically not literally).
Your limit (besides code correctness, which the comments have been pointing out) is going to be based on the maximum integer that Python allows. It turns out Python has theoretically infinite integer precision -- limited by memory.
https://docs.python.org/2/library/stdtypes.html#numeric-types-int-float-long-complex
There are four distinct numeric types: plain integers, long integers, [...]. Plain integers (also just called integers) are implemented using long in C, which gives them at least 32 bits of precision (sys.maxint is always set to the maximum plain integer value for the current platform, the minimum value is -sys.maxint - 1). Long integers have unlimited precision. [...]
So if you take sys.maxint and increase it, you still get an integer:
In [6]: sys.maxsize ** 10
Out[6]: 4455508415646675013373597242420117818453694838130159772560668808816707086990958982033203334310070688731662890013605553436739351074980172000127431349940128178077122187317837794167991459381249L
There will be, however, a performance penalty once you go beyond sys.maxsize.