Here is the code:
import math as m
primeproduct = 5397346292805549782720214077673687806275517530364350655459511599582614290
primes = [2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, 173, 179, 181]
def pseudoroot(n):
print(n)
for i in n:
if n[i] > m.sqrt(primeproduct):
return n[i-1] #greatest divisor below the root
psrprime = pseudoroot(primes)
Running this code gives this error:
Traceback (most recent call last):
File "so.py", line 11, in <module>
print(pseudoroot(primes))
File "so.py", line 7, in pseudoroot
if n[i] > m.sqrt(primeproduct):
IndexError: list index out of range
Which really doesn't make any sense to me as the i in the for loop is a given index in the list and shouldn't exceed the bounds of that list.
primeproddefined?n[i]is the index, not the value. For example, wheniis47, the code is trying to find the value inprimeprodat index 47