Created
June 6, 2011 18:17
-
-
Save tebeka/1010754 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from gmpy import is_prime | |
from math import sqrt | |
def largest_prime_factor(n): | |
for i in xrange(int(sqrt(n)), 1, -1): | |
if (n%i == 0) and is_prime(i, 100): | |
return i | |
def main(): | |
print largest_prime_factor(600851475143) | |
if __name__ == "__main__": | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment