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

Adding every number below 10 that is a multiple of three or five totals 23.

Input:n = 16
Output:60
Explanation:

Adding every number below 16 that is a multiple of three or five totals 60.

Input:n = 1
Output:0
Explanation:

Adding every number below 1 that is a multiple of three or five totals 0.

Constraints

  • 1 ≤ n ≤ 10⁶

Ready to solve this problem?

Practice solo and sharpen your skills for technical interviews.