PE1, with tail recutsion.
PE1, using higher functions.