<?php $answer = 0; $answer_count = 0; for($i = 2 ; $i < 1000000; $i++) { $num = $i; $count = 1; while($num != 1) { if($num % 2 == 0) { $num = $num / 2; } else { $num = 3 * $num + 1; } $count++; } if($answer_count < $count) { $answer = $i; $answer_count = $count; } } echo $answer; ?>