complete euler #3 in JS