Cover image for LeetCode Daily Problem P1716: Calculate Money in Leetcode Bank

LeetCode Daily Problem P1716: Calculate Money in Leetcode Bank


Timeline

timeline

2025-10-26

init

mathematics

Problem:

Very simple math problem

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
struct Solution;

impl Solution {
pub fn total_money(n: i32) -> i32 {
let week = n / 7;
let day = n % 7;

// 1,2 (1+2)*2/2

28 * week + 7 * (week - 1) * week / 2 + (week + 1 + week + day) * day / 2
}
}

fn main() {
println!("Hello, world!");
}