Interview Questions 1
Interview Question 1
Q. Find Factorial of a number?//0 =1 , 1 =1 , 2 =2 , 3 =6 function fact(n){ return n === 0 ? 1 : n *fact(n-1) ;} Q. Find nth Fibonacci number? //0,1,1,2,3,5,8,13,21 function fib(n){ return n < 1 ? 0 : n<=2 ? 1 : fib(n-1)+ fib(n-2);}