Ivankooo1

Factorial Division

Dec 23rd, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function solve(n,n1){
  2.  
  3.   let solution = factorial(n) / factorial(n1);
  4.  
  5.   console.log(solution.toFixed(2))
  6.  
  7.   function factorial(num){
  8.     if(num < 0){
  9.       return -1;
  10.     }
  11.     else if(num === 0){
  12.       return 1;
  13.     }else{
  14.       return (num * factorial(num -1));
  15.     }
  16.   }
  17.  
  18. }
  19. solve(5,2);
Advertisement
Add Comment
Please, Sign In to add comment