Skip to content

Instantly share code, notes, and snippets.

@mcvarer
Created October 19, 2020 20:07
Show Gist options
  • Save mcvarer/a6cab1570252e10dcc09522f5ba99879 to your computer and use it in GitHub Desktop.
Save mcvarer/a6cab1570252e10dcc09522f5ba99879 to your computer and use it in GitHub Desktop.
"""
The prime factors of 13195 are 5, 7, 13 and 29.
What is the largest prime factor of the number 600851475143 ?
"""
def largestPrimeFactor(flt: int, n: int) -> int:
while flt ^ 2 < n:
while n % flt == 0:
n = n // flt
flt += 1
return n
print("largest prime factor of the number = {}".format(largestPrimeFactor(flt=2, n=600851475143)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment