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 = 7
Output:21
Explanation:

3+5+6+7=21.

Input:n = 1
Output:0
Explanation:

No numbers from 1 to 1 are divisible by 3, 5, or 7, so the sum is 0.

Input:n = 15
Output:105
Explanation:

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³

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!