Finding the terms and sum of an arithmetic progression