Javascript solution for Eurler's problem 1