solved p1 of project euler for hackerrank