Finding the next terms in the sequence