Skip to content

Instantly share code, notes, and snippets.

@hails
Created November 23, 2014 00:27
Show Gist options
  • Save hails/dd6d1961ace274f55d21 to your computer and use it in GitHub Desktop.
Save hails/dd6d1961ace274f55d21 to your computer and use it in GitHub Desktop.
#!/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