• + 2 comments

    Simple Code with explanation:

    int chocolateFeast(int n, int c, int m) {
        int choco=n/c,eat=0,wp=0;
        while(choco>0){  //add until chocolate=0
            eat+=choco;
            wp+=choco;   //counting no. of chocolates as wrappers
            choco=wp/m;  //No. of wrappers turned
            wp=wp%m;     //left wrappers
        }
        return eat;
    }