Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- class Task5_5_1 {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- int check_value = sc.nextInt();
- int i;
- if((check_value % 2) != 0) {
- System.out.println("Invalid input");
- }
- else{
- for (i = 3; i <= (check_value / 2); i += 2) {
- if (isPrime(i) && isPrime(check_value-i)) {
- System.out.println(i + " "+(check_value-i));
- }
- }
- }
- }
- public static boolean isPrime(int n) {
- if ((n % 2) == 0) {
- return false;
- }
- for (int i = 3; i < Math.sqrt(n); i += 2) {
- if ((n % i) == 0) {
- return false;
- }
- }
- return true;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment