Answer to Question define-9

  // nextPerfect(n) returns the smallest perfect
  // number that is larger than n.

  int nextPerfect(int n)
  {
    int k = n+1;
    while(!isPerfect(k))
    {
      k++;
    }
    return k;
  }