Hello so today I've decided to start learning Python. I'm studying c++ in school and programming in c++ for about 1 year, so I thought it'll be a great idea to start writing base algorithms from c++ to python. I want to write the the greatest common divisor in python but it gives me this error:
File "d:\proiecte\c++ to python algorithms\cmmdc.py", line 12, in <module>
print(cmmdc(a,b))
File "d:\proiecte\c++ to python algorithms\cmmdc.py", line 7, in cmmdc
return cmmdc(b, a % b)
TypeError: not all arguments converted during string formatting
here is the code:
print ("alorithm to solve gcd from c++ to python! ")
def cmmdc(a, b):
if b == 0:
return a
else:
return cmmdc(b, a % b)
print ("write the first number: ")
a = input()
print ("write the second number: ")
b = input()
print(cmmdc(a,b))