NPTEL solution
Solution for NPTEL Programming, Data Structures and Algorithms using Python Week 1 MCQs
1)What would happen if we call gcd(m,n) with m positive and 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)))
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)))
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)))