Project Euler Question 14 (Collatz Problem)

The reason you’re stalling is because you pass through a number greater than 2^31-1 (aka INT_MAX); try using unsigned long long instead of int. I recently blogged about this; note that in C the naive iterative method is more than fast enough. For dynamic languages you may need to optimize by memoizing in order to … Read more