<?php $b=0; fscanf(STDIN, "%d", $a); while($a!=1) { if($a%2==0) { $a/=2; } else { $a=(3*$a+1)/2; } $b++; } echo($b-1); }