Finished 5, rather ugly, but answer is 232792560
This commit is contained in:
38
5/main.py
Normal file
38
5/main.py
Normal file
@@ -0,0 +1,38 @@
|
|||||||
|
import os
|
||||||
|
import numpy
|
||||||
|
|
||||||
|
|
||||||
|
# Find the smallest number that is divisible by all numbers from 1 to 20
|
||||||
|
|
||||||
|
|
||||||
|
def isDivisible(n, ms):
|
||||||
|
res = True
|
||||||
|
|
||||||
|
for m in ms:
|
||||||
|
if n % m != 0:
|
||||||
|
res = False
|
||||||
|
break
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
def findSmallestDivBy(ns):
|
||||||
|
res = 1
|
||||||
|
|
||||||
|
while not isDivisible(res, ns):
|
||||||
|
res = res + 1
|
||||||
|
|
||||||
|
return res
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
print("Hello, this is Patrick")
|
||||||
|
|
||||||
|
x = findSmallestDivBy([2, 3, 4, 5, 7, 8, 9, 11, 13, 16, 17, 19])
|
||||||
|
print(x)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
Reference in New Issue
Block a user