Hercy saves money every day. On the first Monday he deposits $1, and each following day he deposits $1 more than the day before. Every new Monday he deposits $1 more than the previous Monday. Return the total amount in the bank at the end of day n.
Hercy saves money every day. On the first Monday he deposits 1,andeachfollowingdayhedeposits1 more than the day before. Every new Monday he deposits $1 more than the previous Monday. Return the total amount in the bank at the end of day n.
Example 1:
Input: {"n":4}
Output: 10
Constraints:
1≤n≤1000
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"n":4}
4 days = 0 full weeks + 4 leftover days. Each row of the calendar is one week, starting on Monday.
deposits by week · 4 days = 0 × 7 + 4
Mon
Tue
Wed
Thu
Fri
Sat
Sun
week
1
2
3
4
#1
running total
full weeks: 28·0 + 7·0·0/2 → 0
leftover: 4·1 + 4·3/2 → 0
Week k (from 1) deposits k, k+1, ..., k+6, so each full row sums to 7k + 21.