object MainObject {
def main(args: Array[String]) {
var result = recur(15,2)
print(result)
}
def recur(a:Int,b:Int):Int={
if(b==0)
0
else
a+recur(a,b-1)
}
}
in this above code, can somebody explain to me how step by step this gets executed?
Please correct me if I am wrong: after else there is recur function does this call recur(15,2) in each iteration? By deducting on each time? If yes then at 3rd run b will be 0, so why it doesn't return 0 as that if becomes true.