Project Euler in JS