Finding the nth term and solving equations