Skip to content

Latest commit

 

History

History
18 lines (12 loc) · 432 Bytes

29.md

File metadata and controls

18 lines (12 loc) · 432 Bytes
int totalMoney(int n) {
        
        int k=n/7;     //total weeks
                    // 1st week  -> 1+2+3..+7=28
                    //2nd week   -> 2+3+4..+8=35

        int sum=(k*(2*28+(k-1)*7))/2;

        for(int day=0;day<n%7;day++)
            sum+=(k+1)+day;

        return sum;

    }