Implementation of Wilson Primality test | C ++ implementation to check if a number is prime or not using Wilson Primality Test ; Function to calculate the factorial ; Function to check if the number is prime or not ; Driver code
#include <bits/stdc++.h> NEW_LINE using namespace std ; long fact ( const int & p ) { if ( p <= 1 ) return 1 ; return p * fact ( p - 1 ) ; } bool isPrime ( const int & p ) { if ( p == 4 ) return false ; return bool ( fact ( p >> 1 ) % p ) ; } int main ( ) { cout << isPrime ( 127 ) ; return 0 ; }