function to detect prime number here we have used sieve method https : www . geeksforgeeks . org / sieve - of - eratosthenes / to detect prime number
void sieve ( int n , bool prime [ ] ) { for ( int p = 2 ; p * p <= n ; p ++ ) {