C # implementation of above approach
using System ; using System . Collections . Generic ; class GfG { static bool [ ] prime = new bool [ 1000000 + 5 ] ; static void findPrime ( ) { Array . Fill ( prime , true ) ; prime [ 1 ] = false ; for ( int p = 2 ; p * p <= 1000000 ; p ++ ) {