I have written a function that should check whether an integer is prime, using the Wilson theorem. However it outputs that 5 is not a prime number, which obviously is. I want to ask why is that?
#include <iostream>
using namespace std;
long int counter = 1;
bool primeWilson(int n)
{
for(int i=1; i<n; i++)
{
counter*=i;
}
if(n%(counter+1)!=0)
{
return true;
}
return false;
}