Project Eulter's code solution in C++