Lab Minutes Forum

Technical Discussion => Other => Topic started by: rthurber on August 21, 2013, 09:53:25 PM

Title: Puzzle
Post by: rthurber on August 21, 2013, 09:53:25 PM
Prove that the following program always terminates for any positive integer

sub doIterminate($count) {

$num = int($count);
   while($num != 1) {
      if(($num%2) == 0) {
         $num = $num/2;
      } else {
         $num = 3 * $num + 1;
      }
   }

}
SimplePortal 2.3.7 © 2008-2024, SimplePortal