/ Published in: Python
                    
                                        
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
#!/usr/bin/python
# Project Euler - Problem 3
# What is the largest prime factor of a number?
print "\nProject Euler - Problem 3 "
print "This short program finds the largest"
print "prime factor of a specified integer."
number = input("\nTo begin, Please enter a number: ")
i = 2
fact = 0
n = number
while n > 1:
if n % i == 0: # divisible
if fact < i:
fact = i
n = n / i
i = 2
else:
i = i + 1
print fact
Comments
 Subscribe to comments
                    Subscribe to comments
                
                