i m unable to understand the sample test cases provided. can u please explain them a bit
Question-Not so easy math
there are multiple value of n in test case which test case do you want to understand ? eg n = 5 ,n = 10, n = 12 ?
principle of inclusion and exclusion is applied here. for eg n=6 we have prime numbers 2 and 3 . For 2 anwer is 3 and 3 answer is 2 . we we combine both the answer we will get redundant numbers . now how to remove it?
what you can do find lcm of 2 and 3 and i.e 6 and find its answer and subtract it from (2’s + 3’s) ans. this is inclusion and exclusion. A union B = A + B - (A intersection B)
sir i was thinking about this approach but it would make code too big
isnt there any shorter approach
this is the only method and code is of few lines just you have to find all the subsets . use bitmasking for that. there are 9 primes total of 2^9 subsets.
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.