Working through Project Euler in JavaScript.