Last active
August 29, 2015 14:04
-
-
Save zombrodo/5f000d9ab17cb0d3b27e to your computer and use it in GitHub Desktop.
Wilsons Theorem :: Stupid Integers.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// There is something not right here... | |
#include <stdio.h> | |
long f(int x); | |
int main(void){ | |
int p; | |
printf("WILSONS THEORM for PRIME NUMBERS\nPlease enter a number: "); | |
scanf("%d", &p); | |
int ans = (f(p - 1) + 1) % p; | |
if(ans == 0) printf("%d IS a prime number!: ( %d - 1 )! + 1 mod ( %d == 0)\n", p, p, p); | |
else printf("%d is NOT a prime number!\n", p); | |
} | |
long f(int x){ | |
int i, ret = 1; | |
for(i = 1; i <= x; i++) ret *= i; | |
return ret; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment