Write pseudocode for computing GCD (m,n) where m=525 and n=125 and calculate worst time complexity of the problem. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Write pseudocode for computing GCD (m,n) where m=525 and n=125 and calculate worst time complexity of the problem.

Algorithm

2nd Mar 2019, 3:09 PM
S. Sabui
S. Sabui - avatar
5 Answers
+ 3
by the way: mod --> modulus operator (in many languages %) the mod operator calculates the remainder of a division
2nd Mar 2019, 7:23 PM
Denise Roßberg
Denise Roßberg - avatar
2nd Mar 2019, 7:33 PM
Denise Roßberg
Denise Roßberg - avatar
+ 2
I know the euclidian algorithm to calculate the gcd: 525 mod 125 = 25 125 mod 25 = 0 --> gdc (525,125) = 25 remainder = m mod n while (remainder != 0) m = n n = remainder remainder = m mod n end while print n //remainder is 0 --> n is your gcd But I don't know how to caculate the time complexity.
2nd Mar 2019, 7:17 PM
Denise Roßberg
Denise Roßberg - avatar
+ 1
Thanks.
2nd Mar 2019, 7:20 PM
S. Sabui
S. Sabui - avatar
0
I know the GCD. But don't know how to calculate the worst time complexity of this problem. I have doubt about the last question
2nd Mar 2019, 7:32 PM
S. Sabui
S. Sabui - avatar