Handling large integers in python [migrated]
- by Sushma Palimar
I had written a program in python to find b such that a prime number p divides b^2-8. The range for b is [1, (p+1)/2].
For small integers it works, say only up to 7 digits. But not for large integers, say for p = 140737471578113. I get the error message
for i in range (2,p1,1):
MemoryError
I wrote the program as
#!/usr/bin/python3
p=long(raw_input('enter the prime number:'))
p1=long((p+1)/2)
for i in range (2,p1,1):
s = long((i*i)-8)
if (s%p==0):
print i