-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp005.py
More file actions
33 lines (24 loc) · 687 Bytes
/
p005.py
File metadata and controls
33 lines (24 loc) · 687 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#
# Solution to Project Euler problem 5
# Copyright (c) Andrea Fresco. All rights reserved.
#
# https://projecteuler.net/problem=5
# https://github.com/andreafresco/Project-Euler
#
def GCD(a,b): # Greatest common divisor with EULER FORMULA
while a!=b:
if a>b:
a = a-b
if b>a:
b = b-a
return a
def mcm(a,b): # minimum common multiple
return a*b//GCD(a,b)
def SmallestMultiple(N_max):
prod = 1
for i in range(1, N_max+1):
prod = mcm(prod, i) # minimum common multiple of all the numbers
# between 1 and N_max
return prod
if __name__ == "__main__":
print(SmallestMultiple(20))