Algorithm to obtain pentagonal numbers.