Skip to content

Instantly share code, notes, and snippets.

@FirePanther
Last active November 17, 2016 03:44
Show Gist options
  • Save FirePanther/494a15444c6f79a12d46 to your computer and use it in GitHub Desktop.
Save FirePanther/494a15444c6f79a12d46 to your computer and use it in GitHub Desktop.
public static boolean prim(int zahl) {
if (zahl == 2) return true;
else if (zahl == 1 || zahl % 2 == 0) return false;
else {
for(int i = 3; i <= Math.ceil(Math.sqrt(zahl)); i += 2) {
if (zahl % i == 0) return false;
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment