0

What is wrong with my code??

def gcd(m,n): i =min(m,n) While i>0: if (m%i)==0 and (n%i)==0: return(i) else: i=i-1 m=int(input()) n=int(input())

5th Jan 2022, 7:02 PM
Manish Kumar Y
3 Answers
+ 1
You don't print anything and don't call the function, it should be something like this: print (gcd(n, m))
5th Jan 2022, 7:23 PM
Paul
Paul - avatar
+ 1
your function should work well to get the greatest common divisor if you used strictly positive integers. for the input of gcd function make sure that the number are greater than 0 otherwise you'll get None after you call the function. with your code if you did print(gcd(12,3)) you'll get 3 but if you did print(gcd(12,-3)) you'll get None. don't forget to call the function and print the result after the input method.
5th Jan 2022, 11:37 PM
YoPycode
0
Python has strict format requirements, especially the indent.
5th Jan 2022, 7:18 PM
FanYu
FanYu - avatar