text: Composite Number | A optimized school method based C # 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
code: using System ; namespace Composite { public class GFG { public static bool isComposite ( int n ) { if ( n <= 1 ) return false ; if ( n <= 3 ) return false ; if ( n % 2 == 0 n % 3 == 0 ) return true ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return true ; return false ; } public static void Main ( ) { if ( isComposite ( 11 ) ) Console . WriteLine ( " true " ) ; else Console . WriteLine ( " false " ) ; if ( isComposite ( 15 ) ) Console . WriteLine ( " true " ) ; else Console . WriteLine ( " false " ) ; } } }