add: solution to the fibonacci exercice using recursion
This commit is contained in:
		
							parent
							
								
									0747078d97
								
							
						
					
					
						commit
						52e5b59c91
					
				| 
						 | 
					@ -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
 | 
					// Do not edit below this line
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue