Guest User

Untitled

a guest
Oct 1st, 2017
500
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. /**
  4. * Created by user on 1.10.2017 г..
  5. */
  6. public class p15_FastPrimeCheckerRefactor {
  7. public static void main(String[] args) {
  8.  
  9. Scanner scan = new Scanner(System.in);
  10.  
  11. int input = Integer.parseInt(scan.nextLine());
  12.  
  13.  
  14. for (int i = 2; i <= input; i++) {
  15. String isPrime = "True";
  16. for (int j = 2; j <= Math.sqrt(i); j++) {
  17. if (i % j == 0) {
  18.  
  19. isPrime = "False";
  20. break;
  21. }
  22. }
  23.  
  24. System.out.printf("%d -> %s%n", i, isPrime);
  25. }
  26.  
  27. }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment