{{ message }}

Instantly share code, notes, and snippets.

# russelnickson/projecteuler_prob_3.py

Created Dec 1, 2009
The prime factors of 13195 are 5, 7, 13 and 29. What is the largest prime factor of the number 600851475143 ?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
 a=600851475143 i=2 while i

### imran31415 commented Apr 30, 2013

why does mine take too long to produce an answer.... I tried it with smaller numbers and it seems to work. I would really appreciate the help as i dont understand what makes your code so much smoother than mine (besides the fact its shorter.

def isitprime(n):
k=2
while k<n/2:
if n%k!=0:
pass
else:
k="not prime"
break
k= k+1
if k!="not prime":
k="PRIME"
else:
k="NOT PRIME"
return k

def getprimefactors(n):
bigprime=0
k=n/2
while k>0:
if n%k==0:
a=n/k
if isitprime(a)=="PRIME" and a>bigprime:
bigprime=a
else:
pass
else: pass
k=k-1
print bigprime

print isitprime(6023)
getprimefactors(6023)