Project Euler problem 9 in C