@ParasArora/

chocolate feast

Nodejs

No description

fork
loading
Files
  • index.js
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
function chocolateFeast(n, c, m) {
  let totalChocos = Math.floor(n / c);
  let wrappers = totalChocos;

  while(wrappers >= m){
    let chocolates = Math.floor(wrappers / m);
    wrappers = chocolates + (wrappers % m);
    totalChocos += chocolates;
  }

  console.log(totalChocos);


}

chocolateFeast(12, 4, 4);
chocolateFeast(10, 2, 5);
chocolateFeast(6, 2, 2);
node v10.16.0