public class Primes { public static boolean isAPrime(int number) { if(number == 1 || number == 2) return true; else { for(int i = 3; i*i < number; i +=2) { if (number % i == 0) return false; } } return true; } }
- public class Primes {
- public static boolean isAPrime(int number) {
- if(number == 1 || number == 2) return true;
- else {
- for(int i = 3; i*i < number; i +=2) {
- if (number % i == 0) return false;
- }
- }
- return true;
- }
- }