A simple recursive function – Richard Buckland UNSW