mirror of
https://bitbucket.org/Mattrixwv/projecteulerpython.git
synced 2025-12-06 17:43:58 -05:00
Removed unneccessary imports
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
#ProjectEulter/Python/Project5.py
|
||||
#Matthew Ellison
|
||||
# Created: 01-28-19
|
||||
#Modified: 07-17-20
|
||||
#Modified: 10-29-20
|
||||
#What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
|
||||
#Unless otherwise listed, all of my non-standard imports can be gotten from my pyClasses repository at https://bitbucket.org/Mattrixwv/pyClasses
|
||||
"""
|
||||
@@ -23,14 +23,13 @@
|
||||
|
||||
|
||||
from Problems.Problem import Problem
|
||||
from Stopwatch import Stopwatch
|
||||
from Unsolved import Unsolved
|
||||
|
||||
|
||||
class Problem5(Problem):
|
||||
#Variables
|
||||
__startNum = 1
|
||||
__stopNum = 20
|
||||
__startDivisor = 1
|
||||
__stopDivisor = 20
|
||||
|
||||
#Functions
|
||||
#Constructor
|
||||
@@ -56,7 +55,7 @@ class Problem5(Problem):
|
||||
#Set that it found the number to true, because it sets this flag when it doesn't find it
|
||||
numFound = True
|
||||
#See if the current number is divisible by all numbers from 1 to 20
|
||||
for divisor in range(self.__startNum, self.__stopNum + 1):
|
||||
for divisor in range(self.__startDivisor, self.__stopDivisor + 1):
|
||||
#If it is not set a flag to move to the next possible number
|
||||
if((currentNum % divisor) != 0):
|
||||
numFound = False
|
||||
@@ -66,6 +65,7 @@ class Problem5(Problem):
|
||||
if(not numFound):
|
||||
currentNum += 2
|
||||
|
||||
#Set the smallest number to the number we just found
|
||||
self.smallestNum = currentNum
|
||||
|
||||
#Stop the timer
|
||||
@@ -92,6 +92,7 @@ class Problem5(Problem):
|
||||
raise Unsolved("You must solve the problem before you can get the requested number")
|
||||
return self.smallestNum
|
||||
|
||||
|
||||
#If it are running this file, automatically start the correct function
|
||||
if __name__ == '__main__':
|
||||
problem = Problem5()
|
||||
@@ -104,4 +105,4 @@ if __name__ == '__main__':
|
||||
"""Results:
|
||||
The smallest positive number that is evenly divisible by all numbers 1-20 is 232792560
|
||||
It took an average of 54.833 seconds to run this problem through 100 iterations
|
||||
"""
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user