Find prime factors of Z such that Z is product of all even numbers till N that are product of two distinct prime numbers | C # implementation of the above approach ; Function to print the prime factorization of the product of all numbers <= N that are even and can be expressed as a product of two distinct prime numbers ; sieve of Eratosthenese ; Store prime numbers in the range [ 3 , N / 2 ] ; Print the coefficient of 2 in the prime factorization ; Print the coefficients of other primes ; Driver Code ; Input ; Function calling
using System ; using System . Collections . Generic ; class GFG { static void primeFactorization ( int N ) { int [ ] sieve = new int [ N / 2 + 1 ] ; for ( int i = 0 ; i <= N / 2 ; i ++ ) { sieve [ i ] = 0 ; } for ( int i = 2 ; i <= N / 2 ; i ++ ) { if ( sieve [ i ] == 0 ) { for ( int j = i * i ; j <= N / 2 ; j += i ) { sieve [ j ] = 1 ; } } } List < int > prime = new List < int > ( ) ; for ( int i = 3 ; i <= N / 2 ; i ++ ) if ( sieve [ i ] == 0 ) prime . Add ( i ) ; int x = prime . Count ; Console . WriteLine ( "2 - > " + x ) ; foreach ( int i in prime ) Console . WriteLine ( i + " - > 1" ) ; } public static void Main ( String [ ] args ) { int N = 18 ; primeFactorization ( N ) ; } }