Skip to content

Instantly share code, notes, and snippets.

@lifeparticle
Created January 28, 2021 13:16
Show Gist options
  • Save lifeparticle/1626a6ab1ff831531cb3a5147e205e49 to your computer and use it in GitHub Desktop.
Save lifeparticle/1626a6ab1ff831531cb3a5147e205e49 to your computer and use it in GitHub Desktop.
public static boolean isPrime(int number) {
int factorCount = 0;
for (int i = 1; i <= number; i++) {
if (number % i == 0)
factorCount++;
}
return factorCount == 2 ? true : false;
}
@Elerphore
Copy link

Why not just

return factorCount == 2

on the 7 line?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment