Unterprogramme (Implementierung)

// hat Collatz-Folge von x die Länge len?
static boolean collatz_test (int x, int len) {
  int count = 0; // Deklaration mit Initialisierung
  while (x > 1) {
    if (0 == x % 2) { 
      x = x / 2;
    } else {
      x = 3 * x + 1;    
    }
    count++;
  }
  return len == count;
}



Johannes Waldmann 2006-01-26