#K69467. Sum of Multiples of 3 and 5

    ID: 33093 Type: Default 1000ms 256MiB

Sum of Multiples of 3 and 5

Sum of Multiples of 3 and 5

You are given a positive integer n. Your task is to calculate the sum of all the natural numbers less than n that are multiples of 3 or 5. In other words, you need to compute:

$$ S = \sum_{k=1}^{n-1} \left(\mathbf{1}_{\{k \equiv 0 \; (\mathrm{mod}\; 3) \text{ or } k \equiv 0 \; (\mathrm{mod}\; 5)\}} \cdot k\right)$$

where the indicator function \(\mathbf{1}_{\{\cdot\}}\) is 1 if the condition is true and 0 otherwise. This problem tests your ability to work with loops and conditional statements efficiently.

inputFormat

The input consists of a single integer n provided via standard input. ( n ) is a non-negative integer.

outputFormat

The output is a single integer: the sum of all natural numbers less than n that are divisible by either 3 or 5. The result should be printed to standard output.## sample

10
23