Composite Number | A optimized school method based PHP 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 Code
< ? php function isComposite ( $ n ) { if ( $ n <= 1 ) return false ; if ( $ n <= 3 ) return false ; if ( $ n % 2 == 0 $ n % 3 == 0 ) return true ; for ( $ i = 5 ; $ i * $ i <= $ n ; $ i = $ i + 6 ) if ( $ n % $ i == 0 || $ n % ( $ i + 2 ) == 0 ) return true ; return false ; } if ( isComposite ( 11 ) ) echo " true " ; else echo " false " ; echo " STRNEWLINE " ; if ( isComposite ( 15 ) ) echo " true " ; else echo " false " ; echo " STRNEWLINE " ; ? >