Post

Sergei Kotov
Sergei Kotov@kotov_dev·
@Python_Dv Classic recursive implementation of computing the greatest common divisor. for 20 and 50 a != 0, so call solve(10, 20) for 10 and 20 a != 0, so call (0, 10) for 0, 10 a==0, so print(b) = print(10) Answer: A. 10
English
0
0
8
235
Arun Kumar Singh
Arun Kumar Singh@arunkinsights·
This function is actually an implementation of the Euclidean Algorithm to find the GCD (Greatest Common Divisor) of two numbers. Step-by-step execution: 1. Call: solve(20, 50) a = 20, b = 50 a != 0, so → solve(50 % 20, 20) 50 % 20 = 10 → Next call: solve(10, 20) 2. Call: solve(10, 20) a = 10, b = 20 a != 0, so → solve(20 % 10, 10) 20 % 10 = 0 → Next call: solve(0, 10) 3. Call: solve(0, 10) a = 0, so it prints b → 10 Final Answer: A. 10
English
1
1
4
254
Paylaş