Skip to content

Instantly share code, notes, and snippets.

@kntmr
Created September 4, 2019 03:57
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 kntmr/ad7cc974208014713ddd0bb44235920a to your computer and use it in GitHub Desktop.
Save kntmr/ad7cc974208014713ddd0bb44235920a to your computer and use it in GitHub Desktop.
Prime number
package com.example.demo;
public class PrimeNumber {
boolean primeNumber(int n) {
if (n < 2) return false;
int sqrt = (int) Math.sqrt(n);
for (int i = 2; i <= sqrt; i++) {
if (n % i == 0) {
return false;
}
}
return true;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment