Sum of Multiples of 3 or 5
EasyMath
Description
Given a positive integer n, return the sum of all positive numbers below n that are multiples of three or five.
Examples
Input:
n = 10Output:
23Explanation:
Adding every number below 10 that is a multiple of three or five totals 23.
Input:
n = 16Output:
60Explanation:
Adding every number below 16 that is a multiple of three or five totals 60.
Input:
n = 1Output:
0Explanation:
Adding every number below 1 that is a multiple of three or five totals 0.
Constraints
- •
1 ≤ n ≤ 10⁶