From 16751fc0534755fcb571dce8bf348e9394feaf08 Mon Sep 17 00:00:00 2001 From: harshitha2204 <30696277+harshitha2204@users.noreply.github.com> Date: Sun, 18 Mar 2018 03:21:30 -0500 Subject: [PATCH] Create 5_lcm.py --- 5_lcm.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 5_lcm.py diff --git a/5_lcm.py b/5_lcm.py new file mode 100644 index 0000000..649f379 --- /dev/null +++ b/5_lcm.py @@ -0,0 +1,12 @@ +def gcd(a,b): + while b: + a,b=b,a%b + return a + +def lcm(a,b): + return (a*b)//gcd(a,b) + +x=1 +for i in range(2,21): + x=lcm(x,i) +print(x)