Solving Hackerrank's proejct euler series