Initialize prime [ ] array which will contains all the primes from 1 - N
ArrayList < Integer > prime = new ArrayList < Integer > ( ) ; for ( int p = 2 ; p <= N ; p ++ ) if ( ! primeAll [ p ] ) prime . add ( p ) ;