Personal Project Euler problem solved.