class Sieve {
  
  int[] num;
  
  void initArray() {
    int i = 0;
    while (i < num.length) {
      num[i] = i;
      i=i+1;
    }
  }

  void sieveAll() {
    int i = 2;
    while (i < num.length) {
      sieve(i);
      i=i+1; 
    }
  }

  void sieve(int n) {
    int i = 2*n;
    while (i < num.length) {
      num[i] = 0;
      i=i+n;
    }
  }

  void printPrimes() {
    int i = 2;
    Library.print("Primes less than ");
    Library.printi(num.length);
    Library.print(": ");
    while (i < num.length) {
      if (num[i] != 0) {
        Library.printi(num[i]);
        Library.print(" ");
      }
      i=i+1;
    }
  }


  void main(string[] args) {
    int n;

    if (args.length != 1) {
      Library.println("Unspecified number.");
      return;
    }

    Library.println("");
    n = Library.stoi(args[0], 0);
    if (n <= 0) {
      Library.println("Invalid array length");
      return;
    }
    num = new int[n];

    initArray();
    sieveAll();
    printPrimes();
    Library.println("");
  }
}
