Project Euler problem 6 in C