Created
March 19, 2013 04:33
-
-
Save axelmagn/5193736 to your computer and use it in GitHub Desktop.
find largest prime factor of a number
This file contains 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
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