Solved problem 61 (cyclical figurate numbers), but code is messy.