From 3bdcf0ef251c0fb3ff4cd225772c449dcda4101a Mon Sep 17 00:00:00 2001 From: DEVIL-NEEL Date: Sat, 22 Oct 2022 00:53:43 +0530 Subject: [PATCH] GCD FUNCTION --- GCD.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 GCD.py diff --git a/GCD.py b/GCD.py new file mode 100644 index 0000000..b648ab6 --- /dev/null +++ b/GCD.py @@ -0,0 +1,8 @@ +def gcd(a,b): #gcd function + while (b): #while b not equal to 0 + a,b=b,a%b + return abs(a) + +a,b=map(int,input("Enter 2 numbers: ").split()) #take user input of 2 numbers +c=gcd(a,b) #call the gcd function +print("The gcd of ",a," and ",b," is ",c) #output the result \ No newline at end of file