Advertisement
vladovip

Factorial Division

Feb 7th, 2021
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. function solution(a, b) {
  3.  
  4.     function factorialize(a) {
  5.         if (a < 0)
  6.             return -1;
  7.         else if (a == 0)
  8.             return 1;
  9.         else {
  10.             return (a * factorialize(a - 1));
  11.         }
  12.     }
  13.     factorialize(a);
  14.     let result1 = (factorialize(a));
  15.    
  16.     function factorialize(b) {
  17.         if (b < 0)
  18.             return -1;
  19.         else if (b == 0)
  20.             return 1;
  21.         else {
  22.             return (b * factorialize(b - 1));
  23.         }
  24.     }
  25.     factorialize(b);
  26.     let result2= (factorialize(b));
  27.      
  28.      totalResult= result1/ result2;
  29.      console.log(totalResult.toFixed(2));
  30. }
  31. solution(6, 2);
  32.  
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement