You are viewing a single comment's thread. Return to all comments →
Did almost the same thing in Java8
static int chocolateFeast(int n, int c, int m) { int sum = n / c; if (sum < m) return sum; if (sum == m) return sum + 1; int choc = sum, wrap = choc; do { choc += wrap / m; wrap = (wrap / m) + (wrap % m); } while (wrap >= m); return choc; }
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 →
Did almost the same thing in Java8