Here is the instructions to my code and my code, I am receiving type error:
The greatest common divisor (GCD) of two integers is the largest integer that will evenly divide both integers. Write a program, with comments, that asks the user to input two positive integers and calculates the corresponding GCD. You may assume the user will input valid numbers. Display a suitable message showing the 2 integers and their GCD.
Steps for calculating the GCD is given below.
- set a = to the larger integer and b = the smaller integer (if they are different)
- while b≠0 perform the following steps:
- rem = remainder obtained after dividing a by b
- set a = to the current value of b
- set b = rem (as calculated in step 2a)
- gcd = value of a (i.e. previous value of b) after exiting the while loop.
A sample session showing user inputs and corresponding outputs is given below.
def gcd(a, b):
if b > a:
return gcd(b, a)
if a % b == 0:
return b
return gcd(b, a % b)
a=input('Enter first positive Integer :');
b=input('Enter second positive Integer :');
s = 'The gcd of ' + repr(a) + ' and ' + repr(b) + ' is ' +repr(gcd(a, b))
print(s)

b > ais unnecessary; ifbis bigger on the first iteration, the first recursive call reverses the two values anyway.