Return to Snippet

Revision: 27070
at May 21, 2010 10:35 by chroto


Initial Code
#!/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

Initial URL

                                

Initial Description

                                

Initial Title
Project Euler - Problem 3

Initial Tags

                                

Initial Language
Python