Not So Easy Math / Competitive Course

How to use bitmasking here, any hints

https://online.codingblocks.com/player/16783/content/5117?s=4016

For not so easy Math,
Compute All prime numbers less than 20 and store it in array or vector.
Now
Hint-> Number of number upto n that are divisible by x are n/x.
Number of numbers upto n that are divisible by x and y are n/x+n/y-n/(xy)
Number of number upto n that are divisible by x and y and z are n/x+n/y+n/y-n/(x
y)-n/(yz)-n/(xz)+n/(xyz)

So, use this approach to find number of numbers upto n which are divisble by prime numbers less than 20.
To find all subsets of prime numbers use bitmasking.
Hit like if u get it :slight_smile:

1 Like

Hi

Please check this link

1 Like

Was not getting the intuition of creating subsets, thanks.

Understood it thanks