Advertisement
Guest User

Untitled

a guest
Oct 8th, 2018
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P5_RefactoringPrimeChecker {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scan = new Scanner(System.in);
  7.  
  8. int number = Integer.parseInt(scan.nextLine());
  9. for (int i = 2; i <= number; i++) {
  10. boolean isPrime = true;
  11. for (int j = 2; j < i; j++) {
  12. if (i % j == 0) {
  13. isPrime = false;
  14. break;
  15. }
  16. }
  17. System.out.printf("%d -> %b%n", i, isPrime);
  18. }
  19.  
  20. }
  21.  
  22.  
  23.  
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement