Create Ways to zero.js

pull/1146/head
Shubham Bhati 2023-02-01 04:32:45 +05:30 committed by GitHub
parent af47764be0
commit e6537b8ea3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 0 deletions

View File

@ -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))