My code:
import math
n=int(input('Enter the number'))
b=list(range(2,n+1))
for i in range(2,int(math.sqrt(n))+1):
for j in b:
if j!=i and j%i==0:
b[b.index(j)]=0
b={i for i in b if not i==0}
c={i for i in b if n%i==False}
print(b)
print(c)
This one, I implemented the sieve in my way. Why does it not work for Project Euler question 3 for the number 600851475143? I am getting:
Enter the number600851475143
Traceback (most recent call last):
File "C:/Users/raja/AppData/Local/Programs/Python/Python37-32/ui.py", line 6, in <module>
b=list(range(2,n+1))
OverflowError: Python int too large to convert to C ssize_t
I am just a beginner and self-taught.I'm welcoming all suggestions that are simple and please do point out my mistakes in a kind way:). Thank You.