sicp problem 1.17 in swift