Protip: everyone gets 9. The "math test" is an algorithm that always gives you a multiple of 9, and multiples of 9 below 121 always add up to 9.
Look closely:
Taking away 1, multiplying by 3 and then adding three is the same as multiplying by 3; the 3 that gets added at the end makes up for the 1 that gets subtracted at the start and multiplied by 3. Multiplying the result of this by 3 is the same as multiplying by 9. It would actually be less obvious if the "subtract 1" step were left out, since one would still always end up with two digits that added up to 9 without the two digits making the number that is 9 x whatever you started with). Unless one picked 10. Then it would fuck everything up.