Find all prime numbers smaller than the largest element .
int largest = 0 ; foreach ( int a in arr ) { largest = Math . Max ( largest , a ) ; } List < int > prime = new List < int > ( ) ; SieveOfEratosthenes ( largest , prime ) ;