Finding the term of an arithmetic progression