Project Euler Hackerrank Solutions Algorithm