Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class primeChecker {
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
- int n = input.nextInt();
- boolean isPrime = false;
- if (n == 0 || n == 1 || 0 > n) {
- isPrime = false;
- }
- int counter = 0;
- for (int i = 1; i <= n; i++) {
- if (n % i == 0) {
- counter++;
- }
- }
- if (counter <= 2) {
- isPrime = true;
- }
- System.out.println(isPrime);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment