Skip to content

Instantly share code, notes, and snippets.

@lifeparticle
Created January 28, 2021 13:16
Show Gist options
  • Select an option

  • Save lifeparticle/46d8e6c3e6f1db9eec04a69a0d476296 to your computer and use it in GitHub Desktop.

Select an option

Save lifeparticle/46d8e6c3e6f1db9eec04a69a0d476296 to your computer and use it in GitHub Desktop.
public static boolean isPrime(int number) {
if (number < 2)
return false;
if (number == 2)
return true;
if(number % 2 == 0)
return false;
for (int i = 3; i < number; i+=2) {
if (number % i == 0)
return false;
}
return true;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment