collapse

Promotion

Search


User Info

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

Author Topic: Puzzle  (Read 2055 times)

Offline rthurber

  • Cisco Beginner
  • **
  • Posts: 16
  • Reputation: 55
    • View Profile
    • Gist
  • Certification: CCNP
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