def gcdIter(a, b):
'''
a, b: positive integers
returns: a positive integer, the greatest common divisor of a & b.
'''
test = 0
if a > b:
b = test
else:
a = test
while test != 1:
if a%test == 0 and b%test == 0:
return test
test -= 1
return 1
& bの最大公約数を見つけたいのですが、なぜエラーになるのですか?整数除算またはゼロでモジュロ
何のエラーそれは与える?関数内にコードをインデントしていないように見えます。この場合、コードは関数内にありません。この関数は空であり、SyntaxErrorを送出します。 –
'test = 0' - なぜエラーが出ないのですか? –