Solution for first 50 problem of project euler