Description
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.
Examples
Input:
n = 7Output:
21Explanation:
3+5+6+7=21.
Input:
n = 1Output:
0Explanation:
No numbers from 1 to 1 are divisible by 3, 5, or 7, so the sum is 0.
Input:
n = 15Output:
105Explanation:
Numbers divisible by 3, 5, or 7: 3, 5, 6, 7, 9, 10, 12, 14, 15. Sum = 3+5+6+7+9+10+12+14+15 = 81.
Constraints
- •
1 ≤ n ≤ 10³