PHP - 3n Algorithm
for(;$num1 <= $num2; $num1++) { $k = 1; $num=$num1; while($num != 1) { $num = ($num % 2 == 0) ? ($num / 2) : (3 * $num + 1); $k++; if($k > $l) { $l = $k; } } }