Unterprogramme (Implementierung)

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



Johannes Waldmann 2005-01-25