Finding the nth term and sum of a series