ThreeNPlus1 form solution

 0, * generate a sequence of numbers using the following simple rules: * if N is even, divide it by 2; if N is odd, multiply it by 3 and add 1. * The sequence always converges to 1, although the length of the sequence * varies depending on the choice of N. * * This version uses a simple HTML  element to get user's input. */ ?>   3N + 1 Problem   The 3N + 1 Problem             N:                          '); }      else {               // Otherwise, display the 3N+1 sequence echo "N= $n"; while ($n > 1) {       // While n is greater than 1 echo "$n";     // Print it then either if ($n % 2 == 0) { $n = $n / 2;   //  Divide it by 2 }              else { $n = 3 * $n + 1; // Or multiply 3N+1 }          }       }

?>  