Skip to content

Instantly share code, notes, and snippets.

@dheshanm
Created September 27, 2015 12:35
Show Gist options
  • Save dheshanm/cb91165debcfe6675e70 to your computer and use it in GitHub Desktop.
Save dheshanm/cb91165debcfe6675e70 to your computer and use it in GitHub Desktop.
Prime method for use within Java Programs
public static int Prime(long number) {
long i = 0;
int z=0;
for (long n = 2; n < number; n++) {
if (number % n == 0) {
//System.out.println("The number is not a Prime Number");
i = 1;
z = 0;
break;
}
}
if (i == 0) {
//System.out.println("The number is a Prime Number");
z = 1;
}
return (z);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment