This is my first post here. I am intrigued by such kinds of problems. this is a simple enough JS code, I hope, to achieve the goal.
It is a recursive function, hence I am not expecting very match in terms of performance.
function fib(i){
if (i<=0) return -1;
else if (i==1) return 1;
else if (i==2) return 1;
else return fib(i-1)+fib(i-2)
}
// some examples
//fib(3) returns 2
//fib(5) returns 5
You may try this on chrome dev tools for quick tests.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
This is my first post here. I am intrigued by such kinds of problems. this is a simple enough JS code, I hope, to achieve the goal.
It is a recursive function, hence I am not expecting very match in terms of performance.
You may try this on chrome dev tools for quick tests.