Finding the formula for the Nth term