Mass number is an experimentally determined value. There is no formula to calculate it.
In a question where mass number is asked, the atomic number and number of neutrons will be given.
Moreover, atomic number = number of protons
So, if number of neutrons and atomic number is given, we can calculate the mass number of the given element by adding the two.