I am confused because i think this question as simple set question where

(A u B) = n(A) + n(B) - n(A n B)

Here, total number of students is given then cant we just calculate the common students by using above formula? Why do a range of common students exist?

Scroll down here and you’'ll find the answer to your doubt : https://gre.myprepclub.com/forum/in-a-graduating-class-of-236-students-142-took-algebra-and-1815.html

Tip: You can google ETS question as various approaches for them are freely available on the internet!

Yes, i looked for the solution but my question is what is the problem plugging in values in above formula? I couldn’t figure out why am i getting wrong answer

I believe the question asks for the “Greatest Possible Number of Students”, if you use the formula, you’ll get 27, but that will be the minimum. However, for greatest, we could think of it as students of chemistry are a subset of students who took algebra. So all students who took chemistry also took algebra. If we want to get this using the formula, we might need to change n(A) and n(B).

Here someone has explained it in a more detailed way: elementary set theory - Cardinality of the intersection of two sets - Mathematics Stack Exchange