euler

git clone git://git.codymlewis.com/euler.git
Log | Files | Refs

commit 7b76ded432f4c104c67183cfffbc3c4b3028092c
parent b8ca72f3a4d3662a589559c73830d54fd9235504
Author: Cody Lewis <luxdotsugi@gmail.com>
Date:   Sun, 18 Nov 2018 14:59:50 +1100

Solution to problem 5

Diffstat:
AFive.py | 23+++++++++++++++++++++++
1 file changed, 23 insertions(+), 0 deletions(-)

diff --git a/Five.py b/Five.py @@ -0,0 +1,23 @@ +''' +2520 is the smallest number that can be divided by each of the numbers from 1 +to 10 without any remainder. + +What is the smallest positive number that is evenly divisible by all of the +numbers from 1 to 20? +''' + + +def find_number(): + n = 1 + while True: # \Theta(n) where n is |N| + for i in range(1, 21): + if (n % i) != 0: + break + if i is 20: + return n + n += 1 + +if __name__ == "__main__": + print("Started finding number...") + print(f"The smallest positive number that is evenly divisible by all of " + + f" [1, 20] is {find_number()}")