Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class RefactoringPrimeChecker {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.nextLine());
- for (int firstDigit = 2; firstDigit <= n; firstDigit++) {
- boolean isPrime = true;
- for (int secondDigit = 2; secondDigit < firstDigit; secondDigit++) {
- if (firstDigit % secondDigit == 0) {
- isPrime = false;
- break;
- }
- }
- System.out.printf("%d -> %b%n", firstDigit, isPrime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment