Skip to content

Instantly share code, notes, and snippets.

@shohan4556
Created February 8, 2015 19:24
Show Gist options
  • Select an option

  • Save shohan4556/6320552d1815e63dd419 to your computer and use it in GitHub Desktop.

Select an option

Save shohan4556/6320552d1815e63dd419 to your computer and use it in GitHub Desktop.
wilson's thorem implemt in C
#include<stdio.h>
int main()
{
int n,m,i,p,fact;
while(scanf("%d",&n)==1){
fact=1;
m=n;
for(i=1;i<=n-1;i++){
fact=(fact*i) %m;
}
if (fact==n-1)
printf("%d is prime\n",n);
else
printf("%d is not prime\n",n);
}
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment