#K75542. Sum of Multiples
Sum of Multiples
Sum of Multiples
You are given a positive integer \(N\). Your task is to calculate the sum of all positive integers less than \(N\) that are divisible by either 3 or 5.
More formally, compute the sum of all integers \(i\) such that \(1 \leq i < N\) and \(i \mod 3 = 0\) or \(i \mod 5 = 0\). That is, find \(S\) where:
\[ S = \sum_{i=1}^{N-1} \mathbf{1}_{(i \equiv 0 \; (\mathrm{mod}\; 3) \; \text{or}\; i \equiv 0 \; (\mathrm{mod}\; 5))} \times i \]
For example, when \(N = 10\), the numbers less than 10 that are divisible by 3 or 5 are 3, 5, 6, and 9, and their sum is \(23\).
inputFormat
The input consists of a single integer \(N\), representing the upper bound (exclusive) for the calculation.
You need to read the input from standard input (stdin).
outputFormat
Output a single integer which is the calculated sum of all positive integers less than \(N\) that are divisible by either 3 or 5. Write the result to standard output (stdout).
## sample10
23
</p>