Solving some project euler problems in javascript