2652. Sum Multiples Easy

@problem@discussion
#Math



1/**
2 * [2652] Sum Multiples
3 *
4 * Given a positive integer n, find the sum of all integers in the range [1, n] inclusive that are divisible by 3, 5, or 7.
5 * Return an integer denoting the sum of all numbers in the given range satisfying the constraint.
6 *  
7 * <strong class="example">Example 1:
8 * 
9 * Input: n = 7
10 * Output: 21
11 * Explanation: Numbers in the range [1, 7] that are divisible by 3, 5, or 7 are 3, 5, 6, 7. The sum of these numbers is 21.
12 * 
13 * <strong class="example">Example 2:
14 * 
15 * Input: n = 10
16 * Output: 40
17 * Explanation: Numbers in the range [1, 10] that are divisible by 3, 5, or 7 are 3, 5, 6, 7, 9, 10. The sum of these numbers is 40.
18 * 
19 * <strong class="example">Example 3:
20 * 
21 * Input: n = 9
22 * Output: 30
23 * Explanation: Numbers in the range [1, 9] that are divisible by 3, 5, or 7 are 3, 5, 6, 7, 9. The sum of these numbers is 30.
24 * 
25 *  
26 * Constraints:
27 * 
28 * 	1 <= n <= 10^3
29 * 
30 */
31pub struct Solution {}
32
33// problem: https://leetcode.com/problems/sum-multiples/
34// discuss: https://leetcode.com/problems/sum-multiples/discuss/?currentPage=1&orderBy=most_votes&query=
35
36// submission codes start here
37
38impl Solution {
39    pub fn sum_of_multiples(n: i32) -> i32 {
40        0
41    }
42}
43
44// submission codes end
45
46#[cfg(test)]
47mod tests {
48    use super::*;
49
50    #[test]
51    fn test_2652() {
52    }
53}
54


Back
© 2025 bowen.ge All Rights Reserved.