Skip to content

Instantly share code, notes, and snippets.

@axelmagn
Created March 19, 2013 04:33
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save axelmagn/5193736 to your computer and use it in GitHub Desktop.
Save axelmagn/5193736 to your computer and use it in GitHub Desktop.
find largest prime factor of a number
def largest_prime_factor(num):
i = 2
largest_pfactor = 0
while i <= num:
if num % i == 0:
largest_pfactor = i
num /= i
else:
i += 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment