私はPythonで分割して掛け算する2つの再帰関数を作成しなければなりません:答えがあれば== "M":print(mult(a、b))
def mult(a, b):
if a == 0:
return 0
elif a == 1:
return b
else:
return mult(a-1, b) + b
def div(a, b):
if (a >= b):
return div(a - b, b) + 1
else: return 0
def main():
a = input("Please enter your first value.\n")
b = input("Please enter your second value.\n")
answer = input("Please enter M or D. M to multiply your 2 values or D for Divide.\n")
if answer == "M":
print(mult(a, b))
elif answer == "D":
print(div(a, b))
main()
何が間違っていますか? – zondo