Finding the term of a sequence