S
S
Serge X2015-06-30 21:05:43
Mathematics
Serge X, 2015-06-30 21:05:43

How many numbers less than 240 are not divisible by 2, 3, or 5?

How to solve this problem on paper?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Ruchkin, 2015-06-30
@iamhated

Count those that are divisible by at least one. It should be borne in mind that some numbers will be counted several times. You need to use the inclusion-exclusion formula .
Total divisible by at least one of these numbers:
240/2 + 240/3 + 240/5 - 240/(2*3) - 240/(2*5) - 240/(3*5) + 240/(2 *3*5) = 176
So, non-fissile 240 - 176 = 64
Check:

ghci> length $ filter (\x -> 0 `notElem` [x `mod` 2, x `mod` 3, x `mod` 5]) [1..240]
64

S
sim3x, 2015-06-30
@sim3x

python

In [4]: 240 - len([x for x in range(1, 241) if x % 2 == 0 and x % 3 and x % 5])
Out[4]: 176

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question