projecteuler.net solved in javascript