Project Euler Number 3
unknown
python
2 years ago
589 B
10
Indexable
import time
from math import sqrt
start_time=time.time()
def prime_no(a):
for i in range(2,a-1):
if a%i ==0:
return False
return True
def firstfact(a):
factor=0
for i in range(2,(int(sqrt(a))+1)):
if prime_no(i):
if a%i==0:
factor=i
return factor
break
number_for_tree=600851475143
a=number_for_tree
while True:
a=int(a/firstfact(a))
if prime_no(a):
print(a)
break
print("%s seconds" % (time.time()-start_time))Editor is loading...
Leave a Comment