# How many natural numbers less than 1,000,000,000 are multiples of 5 or 7?

I used the Inclusion-Exclusion Principle and I got $200,000,000$ (multiples of $5$ less than $10^9$, obtained by $10^9 / 5$) + $124,857,142$ ( multiples of $7$ less than $10^9$, obtained by $10^9 / 7$ and round it down) - $28,571,428$ ( multiples of both $5$ and $7$ that are less than $10^9$, obtained by $10^9 / 35$ because only multiples of $35$ is multiple of both $5$ and $7$ ) since the rule says $|A ∪ B| = |A| + |B| - |A ∩ B|$.

So my equation is: $200,000,000 + 124,857,142 - 28,571,428 = 314,285,714$, which is a rather big number so I think I might have done something wrong. Is my reasoning correct? Please help. Thank you!

• It is 142857142 not 124857142. Otherwise your reasoning is correct, and this big number is normal. – Sean Lo Oct 16 '14 at 0:33
• I see, thank you guys very much for helping out! – bodygued Oct 16 '14 at 0:36

counter = 0
i = 0;
while i < 1000000000{
if i % 5 == 0 or i % 7 == 0 {
counter = counter + 1;
}
i = i + 1;
}