Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by user on 1.10.2017 г..
- */
- public class p15_FastPrimeCheckerRefactor {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- int input = Integer.parseInt(scan.nextLine());
- for (int i = 2; i <= input; i++) {
- String isPrime = "True";
- for (int j = 2; j <= Math.sqrt(i); j++) {
- if (i % j == 0) {
- isPrime = "False";
- break;
- }
- }
- System.out.printf("%d -> %s%n", i, isPrime);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment