Created
November 23, 2014 00:27
-
-
Save hails/dd6d1961ace274f55d21 to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env python | |
def factors(x): | |
return (y for y in xrange(2, x/2 + 1) if x % y == 0) | |
def is_prime(x): | |
for i in xrange(2, x/2 + 1): | |
if x % i == 0: | |
return False | |
return True | |
def prime_factors(factors): | |
return (x for x in factors if is_prime(x)) | |
print max(prime_factors(factors(600851475143))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment