Calculating specific terms of an arithmetic progression