Solved exercise 9 from numeral systems