Project Euler problem 15 in C