def gcdIter(a, b): ''' a, b: positive integers returns: a positive integer, the greatest common divisor of a & b. ''' # Your code here r=1 GCD=1 smaller=b if a>b is True: b=smaller if b>a is True: a=smaller while smaller >=r: if a%r==0 and b%r==0: r=GCD r+=1 else: r+=1 print(GCD) gcdIter(2,4)I know this propably isn't the most efficient way of finding the greatest common denominator, but I don't understand how I'm getting an infinite loop, from what I can tell I have made "r" continually increase by 1 until it is greater than the smallest given integer.
I figured it out, I changed line 10 to "smaller=1"