Express an odd number as sum of prime numbers | Function to check if a number is prime or not . ; Prlets at most three prime numbers whose sum is n . ; if ( isPrime ( n ) ) CASE - I ; else if ( isPrime ( n - 2 ) ) CASE - II ; else CASE - III ; Driver code
function isPrime ( x ) { if ( x == 0 x == 1 ) return false ; for ( let i = 2 ; i * i <= x ; ++ i ) if ( x % i == 0 ) return false ; return true ; } function findPrimes ( n ) { document . write ( n ) ; document . write ( 2 + " " + ( n - 2 ) ) ; { document . write ( 3 + " " ) ; n = n - 3 ; for ( let i = 0 ; i < n ; i ++ ) { if ( isPrime ( i ) && isPrime ( n - i ) ) { document . write ( i + " " + ( n - i ) ) ; break ; } } } } let n = 27 ; findPrimes ( n ) ;