If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000.
Try other problems here .
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Let's solve a more general problem by using the principle of inclusion-exclusion (PIE):
Find the sum S of the multiples of a and b below (N + 1) , and calculate the sum in our case (a = 3, b = 5, N = 999).
a , b , N ∈ N
Let:
c = a × b
A = ⌊ a N ⌋ = ⌊ 3 9 9 9 ⌋ = 3 3 3 ,
B = ⌊ b N ⌋ = ⌊ 5 9 9 9 ⌋ = 1 9 9 ,
C = ⌊ c N ⌋ = ⌊ 3 × 5 9 9 9 ⌋ = 6 6
Then:
S = 2 A ( A + 1 ) × a + 2 B ( B + 1 ) × b − 2 C ( C + 1 ) × c =
S = 2 3 3 3 ( 3 3 3 + 1 ) × 3 + 2 1 9 9 ( 1 9 9 + 1 ) × 5 − 2 6 6 ( 6 6 + 1 ) × 1 5 = 2 3 3 1 6 8
Remark: The problem can be further generalised to multiple factors by using PIE and the appropriate LCMs.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 |
|
Problem Loading...
Note Loading...
Set Loading...
Using Python: