Explanation
Let $A$ be the set of students who opted for Mathematics, $B$ be the set of students who opted for Physics, and $C$ be the set of students who opted for Chemistry. We are given:
Total number of students $= 140$
$n(A) = \lfloor\frac{140}{2}\rfloor = 70$
$n(B) = \lfloor\frac{140}{3}\rfloor = 46$
$n(C) = \lfloor\frac{140}{5}\rfloor = 28$
$n(A \cap B) = \lfloor\frac{140}{6}\rfloor = 23$
$n(B \cap C) = \lfloor\frac{140}{15}\rfloor = 9$
$n(C \cap A) = \lfloor\frac{140}{10}\rfloor = 14$
$n(A \cap B \cap C) = \lfloor\frac{140}{30}\rfloor = 4$
Using the principle of inclusion-exclusion:
$n(A \cup B \cup C) = n(A) + n(B) + n(C) - n(A \cap B) - n(B \cap C) - n(C \cap A) + n(A \cap B \cap C)$
$n(A \cup B \cup C) = 70 + 46 + 28 - 23 - 9 - 14 + 4 = 102$
The number of students who did not opt for any of the three courses is:
$140 - n(A \cup B \cup C) = 140 - 102 = 38$