Find the number of integers in [1...10000] which are multiples of 2 or multiples 3 or not multiples of 5.
Is this the correct way to solve it?
Let Ai be the set of multiples of i in [1...10000].
|A2| = 10000/2 = 5000
|A3| = 10000/3 = 3333
|A5| = 10000/5 = 2000, not a multiple hence |!A5| = 10000 - 2000 = 8000
|A(2*3*5)| = |A30| = 10000/30 = 333
|A2| + |A3| + |!A5| = 5000 + 3333 + 2000 = 10333
|A2| + |A3| + |!A5| - |A(2*3*5)| = 10333 - 333 = 10000
Is this the correct way to solve it?
Let Ai be the set of multiples of i in [1...10000].
|A2| = 10000/2 = 5000
|A3| = 10000/3 = 3333
|A5| = 10000/5 = 2000, not a multiple hence |!A5| = 10000 - 2000 = 8000
|A(2*3*5)| = |A30| = 10000/30 = 333
|A2| + |A3| + |!A5| = 5000 + 3333 + 2000 = 10333
|A2| + |A3| + |!A5| - |A(2*3*5)| = 10333 - 333 = 10000
-
no thats wrong, because "5" isn't a multiple of 2 or 3 and a multiple of 5. understand?
so the result can't be 10000.
all numbers which are a multiple of 2 are the even numbers => 5000numbers
all numbers which are a multiple of 3 and not of 2 is every third odd number=>
5000odd numbers/3 => 1666numbers
this are 6666numbers + the numbers which aren't a multiple of 5 except the amount of the 6666 numbers
the amount of the numbers which are not a multiple of 5 between 1 and 10000 are 8000numbers, but we need the numbers which aren't allready included in the 6666numbers from before.
so we have to add to these 8000 the numbers of the 6666 which are a multiple of 5.
these are all the multiples of 5*2=10 => 1000numbers and 5*3=15 => 666numbers
the shared space must be subtracted, which are the numbers which are multiple of 15 and 10
10000/30 => 333 numbers (but we subtract them so we must subtract 334, because of the value behind the comma)
so we have: 8000+1000+666-334 = 9332 :D
so the result can't be 10000.
all numbers which are a multiple of 2 are the even numbers => 5000numbers
all numbers which are a multiple of 3 and not of 2 is every third odd number=>
5000odd numbers/3 => 1666numbers
this are 6666numbers + the numbers which aren't a multiple of 5 except the amount of the 6666 numbers
the amount of the numbers which are not a multiple of 5 between 1 and 10000 are 8000numbers, but we need the numbers which aren't allready included in the 6666numbers from before.
so we have to add to these 8000 the numbers of the 6666 which are a multiple of 5.
these are all the multiples of 5*2=10 => 1000numbers and 5*3=15 => 666numbers
the shared space must be subtracted, which are the numbers which are multiple of 15 and 10
10000/30 => 333 numbers (but we subtract them so we must subtract 334, because of the value behind the comma)
so we have: 8000+1000+666-334 = 9332 :D