collapse

Search


User Info

 
 
Welcome, Guest. Please login or register.
Did you miss your activation email?

Author Topic: Puzzle  (Read 2491 times)

rthurber

  • Guest
Puzzle
« 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.5 © 2008-2012, SimplePortal