text: Check if the remainder of N | C # implementation to check the following expression for an integer N is valid or not ; Function to check if a number holds the condition ( N - 1 ) ! % N = N - 1 ; Corner cases ; Number divisible by 2 or 3 are not prime ; Iterate from 5 and keep checking for prime ; Function to check the expression for the value N ; Driver code
code: using System ; class GFG { static bool isPrime ( int n ) { if ( n == 1 ) return true ; if ( n <= 3 ) return true ; if ( n % 2 == 0 n % 3 == 0 ) return false ; for ( int i = 5 ; i * i <= n ; i = i + 6 ) if ( n % i == 0 || n % ( i + 2 ) == 0 ) return false ; return true ; } static void checkExpression ( int n ) { if ( isPrime ( n ) ) Console . Write ( " Yes " ) ; else Console . Write ( " No " ) ; } public static void Main ( ) { int N = 3 ; checkExpression ( N ) ; } }