Composite Number | A optimized school method based Javascript program to check if a number is composite . ; Corner cases ; This is checked so that we can skip middle five numbers in below loop ; Driver Program to test above function
function isComposite ( n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( let i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } isComposite ( 11 ) ? document . write ( " " + " " ) : document . write ( " " + " " ) ; isComposite ( 15 ) ? document . write ( " " + " " ) : document . write ( " " + " " ) ;