Skip to content

Instantly share code, notes, and snippets.

@tebeka
Created June 6, 2011 18:17
Show Gist options
  • Save tebeka/1010754 to your computer and use it in GitHub Desktop.
Save tebeka/1010754 to your computer and use it in GitHub Desktop.
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