phyton | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

phyton

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

2nd Feb 2017, 10:30 AM
vamsi krish
vamsi krish - avatar
1 Answer
0
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)
7th Mar 2017, 6:58 AM
Qwerty