Calculate Money in Leetcode Bank

Easy Topics Company Tags

You start saving on a Monday with a deposit of one dollar. Within each week, the daily deposit increases by one dollar from the previous day. Each new Monday starts with a deposit one dollar larger than the previous Monday. Return the total deposited during the first n days.

Example 1:

Input: n = 7

Output: 28

Explanation: The first week contributes 1 + 2 + 3 + 4 + 5 + 6 + 7 = 28.

Example 2:

Input: n = 8

Output: 30

Explanation: The first seven days contribute 28. The second Monday contributes 2, bringing the total to 30.

Example 3:

Input: n = 15

Output: 66

Explanation: The first two weeks contribute 28 and 35. The third Monday contributes 3, so the total is 28 + 35 + 3 = 66.

Constraints:

  • 1 <= n <= 1000


Topics

Company Tags

Please upgrade to NeetCode Pro to view company tags.