Finding the term in a sequence