Find prime factors of Z such that Z is product of all even numbers till N that are product of two distinct prime numbers | 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 ; Input ; Function calling
function primeFactorization ( N ) { let sieve = new Array ( parseInt ( N / 2 ) + 1 ) . fill ( 0 ) ; for ( let i = 2 ; i <= N / 2 ; i ++ ) { if ( sieve [ i ] == 0 ) { for ( let j = i * i ; j <= N / 2 ; j += i ) { sieve [ j ] = 1 ; } } } let prime = [ ] ; for ( let i = 3 ; i <= N / 2 ; i ++ ) if ( sieve [ i ] == 0 ) prime . push ( i ) ; let x = prime . length ; document . write ( " " + x ) ; document . write ( " " ) for ( let i of prime ) { document . write ( i + " " ) ; document . write ( " " ) ; } } let N = 18 ; primeFactorization ( N ) ;