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.
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.