Post

Kode Gurukul
Kode Gurukul@kodegurukul·
Answer is 10. This is classic example of recursion. Steps: 1⃣ solve(20, 50); a = 20, b = 50; b%a = 10. it will call again solve(10, 20) 2⃣ solve(10, 20); a = 10, b = 20; b%a = 0. it will call again solve(0, 10); 3⃣ solve(0, 10); a = 0, b = 10; When a == 0 it will return b which is 10 So answer is 10.
Kode Gurukul tweet media
English
2
0
16
495
Jagjeet Singh
Jagjeet Singh@jagjeetsinghda·
@Python_Dv 🐍 Python Code 🧮: Recursive function to find the Greatest Common Divisor (GCD) using the Euclidean algorithm. Elegant solution for finding GCD of 20 and 50 returns 10. #Python #Algorithm #CodingFun 🚀
Jagjeet Singh tweet media
English
0
0
1
58
Abayomi Sodiq
Abayomi Sodiq@AbayomiSodiq7·
@Python_Dv The answer is 10. It’s a recursive question. a = 50 mod 20 = 10 Then, solve(10, 20), 20 mod 2 == 0. Finally, we have solve(0, 10).
English
0
0
1
72
Prem Prakash
Prem Prakash@4EverPrem·
@Python_Dv It's a recursive function which will keep calling itself till the time a is equal to 10 and that time, b will be 10
English
0
0
1
124
Dr. Sultan
Dr. Sultan@SultanAcademyUS·
@Python_Dv The answer is 10 this function will keep repeating until a=0 and at that point b=10
English
0
0
1
198
Hamza
Hamza@Hamza_1286·
@Python_Dv New at python . It seems tricky
English
0
0
0
0
varun kumar
varun kumar@VarunInsights·
@Python_Dv This code defines a recursive function called solve that takes two integer arguments, a and b The function is intended to calculate the greatest common divisor (GCD) of a and b using the Euclidean algorithm. And the output of the code is 10
English
0
0
0
5
Paylaş