k
as n / 7
using integer division.F
of the arithmetic sequence to 28 (sum of savings for the first week).L
of the sequence as 28 + (k - 1) * 7
.arithmeticSum
as k * (F + L) / 2
.n % 7
and adding 1 + k + day
for each day.arithmeticSum
and the sum for the final week finalWeek
to get the total savings total
.total
.