PUZZLE PE-001
Multiples of 3 or 5
Project Euler · Problem 1
Original problem
If we list all the natural numbers below
Find the sum of all the multiples of
Formal statement
Let
Compute the finite sum
Hints
Open one at a timeSum multiples of 3 and multiples of 5 separately.
Correct for numbers counted twice.
Solution
Best opened after a real attemptApproach
For any positive integer
Their sum is therefore
This turns a linear scan into a constant-size calculation and makes the overlap explicit.
Code & final result
The original problem is reproduced from Project Euler Problem 1 under CC BY-NC-SA 4.0.