public class Solution { public static void main(String[] args) { for(int i = 3; i <= 1000; i++) if(isDoublePrime(i)) System.out.println("(" + i + ", " + (i + 2) + ")"); } public static boolean isDoublePrime(int n) { if(isPrime(n) && isPrime(n + 2)) return true; else return false; } public static boolean isPrime(int n) { if(n == 1) return false; else if(n == 2) return true; else { for(int i = 2; i < n; i++) { if(n % i == 0) return false; } return true; } } }