From 6e0793753b141842c46c3f05219db884079ce7ac Mon Sep 17 00:00:00 2001 From: geek1834 <44375459+geek1834@users.noreply.github.com> Date: Mon, 22 Oct 2018 22:37:26 +0530 Subject: [PATCH] create lcm_gcd.py solution of lcm of array in python --- lcm_gcd1.py | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 lcm_gcd1.py diff --git a/lcm_gcd1.py b/lcm_gcd1.py new file mode 100644 index 00000000..f42a4590 --- /dev/null +++ b/lcm_gcd1.py @@ -0,0 +1,17 @@ +def find_gcd(x, y): + + while(y): + x, y = y, x % y + + return x + +# Driver Code +l =list(map(int,input().split())) +num1 = l[0] +num2 = l[1] +gcd = find_gcd(num1, num2) + +for i in range(2, len(l)): + gcd = find_gcd(gcd, l[i]) + +print(gcd)