You are viewing a single comment's thread. Return to all comments →
simpiest solution for any language
static int chocolateFeast(int n, int c, int m) { int choc=n/c; int chocCount=0; int prevrem=0; while(choc>0){ chocCount=chocCount+choc; choc=choc+prevrem; if(choc>=m){ prevrem=choc%m; choc=choc/m; } else{ choc=0; } } return chocCount; }
Seems like cookies are disabled on this browser, please enable them to open this website
Chocolate Feast
You are viewing a single comment's thread. Return to all comments →
simpiest solution for any language