phyton | Sololearn: Learn to code for FREE!



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)))

2/2/2017 10:30:04 AM

vamsi krish

1 Answer

New Answer


Hi, the best way to know it is to try it, but if you want to make sure a number is positive, use abs(number)