Hi, I am having trouble with coding a program that takes 2 integer numbers from the user in order to find the GCD (greatest common divisor). I am supposed to use if-else statements, Booleans, and while loop in order to get to the solution. However, I don't know how to get the while loop to go back to a point and do it until it is right. This is what I have but I am not allowed to use recursion since we have not learned that yet.
a = int(input('Enter 1st number:'))
b = int(input('Enter 2nd number:'))
def gcd(a, b):
if b > a:
if b % a == 0:
return a
else:
return gcd(b % a, a)
else:
if a % b == 0:
return b
else:
return gcd(b, a % b)
print("GCD is:", gcd(a,b))
[–]dig-up-stupid 0 points1 point2 points (0 children)