Last active
November 5, 2016 15:56
-
-
Save kjensenxz/2a48011089bcdbf8ebac49ef0000eaee to your computer and use it in GitHub Desktop.
/dpt/ told me to
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
#include <math.h> | |
int isPrime(int n) { | |
int mask = n >> 31; | |
n = (mask ^ n) - mask; | |
if (n < 4) return 1; | |
else if (!(n & 1)) return 0; | |
unsigned short i; | |
for (i = 3; i <= sqrt(n); i+=2) { | |
if (n % i == 0) return 0; | |
} | |
return 1; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment