Last active
October 18, 2016 09:51
-
-
Save BedirYilmaz/7e05a59d47725e486467221d0edbc0ad to your computer and use it in GitHub Desktop.
Find the smallest positive number that is evenly divisible by all of the numbers from 1 to 20
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def divisible (n): | |
if(n % 7 != 0): | |
return False | |
if(n % 9 != 0): | |
return False | |
if(n % 11 != 0): | |
return False | |
if(n % 13 != 0): | |
return False | |
if(n % 16 != 0): | |
return False | |
if(n % 17 != 0): | |
return False | |
if(n % 19 != 0): | |
return False | |
return True | |
divisible(2432902008176640000) | |
search = 7 | |
while True: | |
if(divisible(search)): | |
print(search) | |
break | |
search +=1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment