+ 2

Can someone explain me this code bit ,how the output is 95?

https://code.sololearn.com/c1V6JM945h4n/?ref=app Thanks in advance:))

18th May 2021, 2:52 PM
Nivya
Nivya - avatar
8 Answers
+ 2
Let's start executing the code x=60 So if statement will run X=cbsc(70) Now it will run for 70 X=cbsc(80) For 80 X=cbsc(90) For 90 X=cbsc(100) Now for 100 it return 99 X=cbsc(90) =99 Now it return 98 X=cbsc(80) =97 Doing same X=cbsc(70) =96 X=cbsc(60) =95
18th May 2021, 3:00 PM
YUGRAJ
+ 3
This is how ans is 95 // cbsc(70)-1 // cbsc(80)-1-1 // cbsc(90)-1-1-1 // cbsc(100)-1-1-1-1 // 100-1-1-1-1-1 //95
18th May 2021, 2:58 PM
TOLUENE
TOLUENE - avatar
+ 2
Yeah in recursion if you call a function then it stops the execution of current function and start executing the function which is called after completing that it will continue the execution of current function where it leaves
18th May 2021, 3:19 PM
YUGRAJ
+ 1
Thanks YUGRAJ a load for your patience it's so crystal clear!!
18th May 2021, 3:04 PM
Nivya
Nivya - avatar
+ 1
Yeah absolutely right
18th May 2021, 3:23 PM
YUGRAJ
18th May 2021, 2:59 PM
Nivya
Nivya - avatar
0
not getting, why is it going to the state return , if it is not called until the condition is met? I mean return will be called after completing entire recursion right?idk but I'm breaking here to understand...
18th May 2021, 3:16 PM
Nivya
Nivya - avatar
0
Okay,so it does return for all the functions!! understood finally:)) 60 70 80 90 100 -1 for each so 100-5=95
18th May 2021, 3:22 PM
Nivya
Nivya - avatar