ex6.4 - add annotation to optimise function for tail recursion