Advertisement
nevenailievaa

13. Prime Pairs

Mar 6th, 2024
740
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.83 KB | None | 0 0
  1. package NestedLoopsMoreEx;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class PrimePairs {
  6.     public static void main(String[] args) {
  7.         Scanner scanner = new Scanner (System.in);
  8.  
  9.         int firstCouple = Integer.parseInt ( scanner.nextLine () );
  10.         int secondCouple = Integer.parseInt ( scanner.nextLine () );
  11.         int firstEnd = Integer.parseInt ( scanner.nextLine () );
  12.         int secondEnd = Integer.parseInt ( scanner.nextLine () );
  13.  
  14.         for (int a = firstCouple; a <= firstCouple + firstEnd; a++){
  15.             for (int b = secondCouple; b <= secondCouple + secondEnd; b++){
  16.                 if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0 && b % 2 != 0 && b % 3 != 0&& b % 5 != 0&& b % 7 != 0) {
  17.                     System.out.printf ( "%d%d%n", a, b );
  18.                 }
  19.             }
  20.         }
  21.     }
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement