Greetings!
If anyone can help please do
I am now in the functions chapter of eloquent JavaScript. I am understanding the components of functions however the math is giving me some trouble.
I was experimenting with a concept to see how it works so I wrote this small piece of code…
function range(x) {
if (x >= 10) return 0;
return x + range(x*2);
}
range(1);
The solution comes out to 15
if I plug in range(2):
function range(x) {
if (x >= 10) return 0;
return x + range(x*2);
}
range(2);
The solution returns 14
I cant for the life of me figure out the steps of he math. How it actually stacks up step by step to come to the answers. I know if I understood one I would understand the other. Hope what I am asking for help with is clear. Thanks in advance to anyone who can provide some clarity.