I've written an algorithm that checks if a number is prime or not. it works just fine but when the integer value gets close to 1 million it begins to slow and when it's exactly 1 million it gets stuck trying to determine if it's prime or not.
here's is what i've tried
def isPrime(n):
c = []
for i in range(1, n+1):
if i % i == 0 and n % i == 0:
c.append(i)
if len(c) > 2 or len(c) == 1:
return(0)
return(1)
https://pastebin.com/embed_js/CKC4sGFy
def factors(n):
for i in range(1, n+1):
if n % i == 0:
if isPrime(i):
print(i)
here i wrote another algorithm for prime factors calling on the prime checker