These numbers are called coefficients of relationships. In order to calculate them you have to first understand that through meiosis and gametogenesis, each parent roughly transfers 1/2 of his genome to each of his progeny. Then using this principle you count the number of paths in the family tree connecting two relatives for whom you are trying to find the coefficient of relationship and then use it in this formula

Rxy = summation (1/2) to the power "n"

where Rxy is the coefficient of relationship between two relatives x and y. and "n" is the number of paths.

I might have missed a few points which could be critical for you to understand the concept, but you can visit the following link, for a better explanation:

http://www.genetic-genealogy.co.uk/Toc115570135.html
Keep in mind that, there would hardly be enough time for you to calculate coefficients of relationship in the exam so the common ones like siblings (1/2), half brothers (1/4), first cousins (1/8), half cousins (1/16) and second cousins (1/32) should be on your fingertips.