Skip to content

Instantly share code, notes, and snippets.

@BenMcH
Last active January 3, 2016 18:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save BenMcH/8500587 to your computer and use it in GitHub Desktop.
Save BenMcH/8500587 to your computer and use it in GitHub Desktop.
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;
}
}
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