Inclusive Exclusive Principal

Coding part: can you please explain the step :
ans+= n/denom and ans-=n/denom

Hello @shellcodingblock,

As sir has explained in the video while observing a general trend in inclusion-exclusion principle:

  1. For the intersection of even numbers of set the sign is -ve.
  2. For the intersection of odd numbers of set the sign is +ve.

Example:
n|2 intersection 3| = ans/(2.3)

Suggestion:
Rewatch the entire video.

Hope, this would help.
Give a like if you are satisfied.

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.