Bespiel-Programm (in Java)

static void compute (int x) {
  int count = 0;
  int max = x;
  System.out.print ("start: " + x);
  while (x > 1) {
    if (0 == x % 2) { 
      x = x / 2;
    } else { 
      x = 3 * x + 1;
    }
    System.out.println (x + " ");
    // TODO: schritte mitzählen
    // TODO: maximum eintragen
  }
  System.out.println (" schritte: " + count + " höchstes: " + max);
}



Johannes Waldmann 2005-01-25