Adding problem number fourteen from project euler coded in JS