0

I cant seem to wrap my head around why this code works. When i try to read through the code i cant get the same answer. Help pls

https://code.sololearn.com/cpJ5j7I74FRh/?ref=app

21st Mar 2022, 7:35 AM
webbxhead
webbxhead - avatar
2 Respuestas
+ 3
Ex : 5 => 5%2 + 10 * convert(5//2) #next call with 2 1 + 10*( 2%2 + 10*(convert(2//2)) ) # 1 1 + 10*( 0 + 10*(1%2+ 10*(convert(1//2))) ) #0 => 1 + 10*( 0 + 10*(1 + 10*0) ) 1+ 10*( 0 + 10*(1)) 1 + 10*(10) = 101 hope it helps..
21st Mar 2022, 8:57 AM
Jayakrishna 🇮🇳
+ 1
Hi! You have to understand recursion to understand how it works. But you can do the calculation with pen an paper to understand the math behind. It’s also important to understand the result is an integer here. Often binary numbers is represented by a string.
21st Mar 2022, 9:38 AM
Per Bratthammar
Per Bratthammar - avatar