#ProjectEuler/Python/Problem3.py #Matthew Ellison # Created: 01-27-19 #Modified: 03-28-19 #The largest prime factor of 600851475143 #Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses """ Copyright (C) 2019 Matthew Ellison This program is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. You should have received a copy of the GNU Lesser General Public License along with this program. If not, see . """ from Stopwatch import Stopwatch from Algorithms import getFactors __targetNumber = 600851475143 def Problem3(): #Get the factors of the number factors = getFactors(__targetNumber) #The largest number will be the answer #Print the results print("The largest prime factor of " + str(__targetNumber) + " is " + str(factors[(len(factors) - 1)])) #If you are running this file, automatically start the correct function if __name__ == '__main__': timer = Stopwatch() #Used to determine the algorithm's run time timer.start() #Start the timer Problem3() #Call the function that answers the question timer.stop() #Stop the timer #Print the results of the timer print("It took " + timer.getString() + " to run this algorithm") """Results: The largest prime factor of 600851475143 is 6857 It took 1.685 seconds to run this algorithm """