Implementation of Wilson Primality test | Function to calculate the factorial ; Function to check if the number is prime or not ; Driver code
def fact ( p ) : NEW_LINE INDENT if ( p <= 1 ) : NEW_LINE INDENT return 1 NEW_LINE DEDENT return p * fact ( p - 1 ) NEW_LINE DEDENT def isPrime ( p ) : NEW_LINE INDENT if ( p == 4 ) : NEW_LINE INDENT return 0 NEW_LINE DEDENT return ( fact ( p >> 1 ) % p ) NEW_LINE DEDENT if ( isPrime ( 127 ) == 0 ) : NEW_LINE INDENT print ( 0 ) NEW_LINE DEDENT else : NEW_LINE INDENT print ( 1 ) NEW_LINE DEDENT