Euler project - P 164

I agree, finding ways to abstract my thinking about the problem.