diff --git a/algorithms/JavaScript/src/recursion/Ways to zero.js b/algorithms/JavaScript/src/recursion/Ways to zero.js new file mode 100644 index 00000000..7539afe3 --- /dev/null +++ b/algorithms/JavaScript/src/recursion/Ways to zero.js @@ -0,0 +1,20 @@ +// Description + +// Given an integer N. In how many ways you can subtract numbers 1, 2, and, 5 from N such that value of N reduces to 0. + + + +function fun(num){ +if(num<0){ + return 0; +} +if(num==0){ + return 1 +} +return fun(num-1)+fun(num-2)+fun(num-5); +} + + + +let num = 4 +console.log(fun(num))