Finding the nth Term in a Sequence