Solution for the problem 1 of Project Euler in C#