Slove problems from Project Euler on Java Script