Hello, hven191!

This doesn't require any fancy formulas . . .

The probability for students at a certain university

to pass Mathematics and Economics are 3/7 and 5/7 respectively.

One student failed both subjects and four students passed both subjects.

Find the number of students who took the test. Make a Venn diagram of the students who passed. Code:

*---------------------------------------*
| |
| *-----------------------* |
| | Math | |
| | only *---------------+-------* |
| | M | Both | | |
| | | 4 | | |
| | | | | |
| *-------+---------------* Eco | |
| | E only | |
| *-----------------------* |
| Neither 1 |
*---------------------------------------*

Let $\displaystyle M$ = number of students that passed Math only.

Let $\displaystyle E$ = number of students that passed Economics only.

We know there are 4 that passed both, and 1 that failed both.

The total number of students is: .$\displaystyle N \:=\:M + E + 5$

The number of students that passed Math is: .$\displaystyle M + 4$

The probability that a student passed Math is $\displaystyle \tfrac{3}{7}$

We have: .$\displaystyle \frac{M+4}{M+E+5} \:=\:\frac{3}{7} \quad\Rightarrow\quad 4M - 3E \:=\:-13\;\;{\color{blue}[1]}$

The number of students that passed Economics is $\displaystyle E + 4$

The probability that a student passes Economics is $\displaystyle \tfrac{5}{7}$

We have: .$\displaystyle \frac{E+4}{M+E+5} \:=\:\frac{5}{7} \quad\Rightarrow\quad 5M - 2E \:=\:3\;\;{\color{blue}[2]} $

$\displaystyle \begin{array}{cccccc}\text{Multiply {\color{blue}[1]} by -2:} & \text{-}8M + 6E &=& 26 & {\color{blue}[3]}\\

\text{Multiply {\color{blue}[2]} by 3:} & 15M - 6E &=& 9 & {\color{blue}[4]}\end{array}$

$\displaystyle \text{Add {\color{blue}[3]} and {\color{blue}[4]}: }\;7M \:=\:35 \quad\Rightarrow\quad\boxed{ M \:=\:5}$

Substitute into [1]: .$\displaystyle 4(5) - 3E \:=\:-13 \quad\Rightarrow\quad\boxed{ E \:=\:11}$

Therefore, the number of students is: .$\displaystyle N \;=\;M + E + 5 \;=\;5 + 11 + 5 \;=\;{\color{red}21}$