add: solution to the fibonacci exercice using recursion

This commit is contained in:
Abdelhakim 2022-08-06 20:35:22 +01:00
parent 0747078d97
commit 52e5b59c91
1 changed files with 7 additions and 1 deletions

View File

@ -1,5 +1,11 @@
const fibonacci = function() {
const fibonacci = function(n) {
n = +n;
if(n<0) return 'OOPS';
if(n == 1 || n == 2){
return 1;
}
return(fibonacci(n-1)+fibonacci(n-2));
};
// Do not edit below this line