+ 1
what wud happen if we call gcd(m,n) with m positive nd n negative in the following definition
def gcd(m,n) : if m < n : (m,n) = (n,m) if (m%n) == 0 : return (n) else : diff = m-n return (gcd(max(n,diff),min(n,diff))) a) the function would still compute gcd correctly b) the function would not terminate c) the behavior depends on the exact values of m and n give reason for ur answer
1 Réponse
0
"c" since m and n aren't defined yet. everything in the else statement is run since none of them is True (btw, you need to use 'elif'). So you would probably get a exception (NameError)