Finding the nth term or sum of an arithmetic progression