Everything you did was exactly correct. You just needed one additional tiny thing. What happens with a? How do you get it to stop when a wants to be defined in terms of a[-1] and a[-1] in terms of a[-2] and...? You include a special case to stop it.