// Johnny Boldt // Apr 3, 2011 // johnny.boldt@gmail.com The key to solving this problem is the line: The input numbers are not greater than 2^32. That means the largest input number can be 2^32. An unsigned long int only goes up to (2^32)-1. So to solve this, one must use a long long int.