1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
| class Solution:
def totalMoney(self, n: int) -> int:
m = n // 7 # number of full weeks
res = 0 # for storing the result
# calculating full weeks
for i in range(1, m + 1):
res += 7 * (i + 3)
# calculating remaining days
for i in range(7 * m, n):
res += m + 1
m += 1
return res
|