Project Euler problem 12 in C