package com.tutego.insel.util;

import java.util.*;

public class Primtest
{
  public static void main( String[] args )
  {
    final int    MAXPRIM = 1000;
    final int    ROOT    = (int) Math.sqrt( MAXPRIM );
    final BitSet bs      = new BitSet();               // Stores non prim

    for ( int i = 2; i <= ROOT; ++i )
      if ( ! bs.get( i ) )
        for ( int j = 2 * i; j <= MAXPRIM; j += i )
          bs.set( j );

    for ( int i = 2; i <= MAXPRIM; i = bs.nextClearBit( i + 1 ) )
      System.out.printf( "%d ", i );
  }
}
