Last active
January 3, 2016 18:09
-
-
Save BenMcH/8500587 to your computer and use it in GitHub Desktop.
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
public class P { | |
static boolean p(long a){ | |
if(a<2)return false; | |
long i = 2; | |
for(;i*i<=a;i+=2){ | |
if(a%i==0)return false; | |
if(i<5)i--; | |
} | |
return true; | |
} | |
} |
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
public class Prime { | |
public static boolean isPrime(long num){ | |
if(num<2)return false; | |
long i = 2; | |
while(i*i<=num){ | |
if(num%i==0)return false; | |
i+=2; | |
if(i<5)i--; | |
} | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment