Euler 2 in JS