Javascript Project Euler Solver