Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * goldback
- */
- public class goldback {
- public static void main(String[] args) {
- int l = 0;
- Scanner sc = new Scanner(System.in);
- System.out.println("enter a number");
- int s = sc.nextInt();
- if (s % 2 != 0) {
- System.out.println("invalid input odd number");
- System.exit(0);
- }
- int[] ar = new int[s];
- for (int i = 2; i < s; i++) {
- if (lla(i)) {
- ar[l] = i;
- l++;
- }
- }
- for (int i = 0; i < ar.length; i++) {
- int k = ar[i];
- for (int j = 0; j < ar.length; j++) {
- if (k + ar[j] == s) {
- System.out.println(k + " " + ar[j]);
- ar[i] = 0;
- }
- }
- }
- sc.close();
- }
- public static boolean lla(int i) {
- int count = 0;
- for (int j = 2; j < i; j++) {
- if (i % j == 0) {
- count++;
- }
- }
- if (count == 0) {
- return true;
- } else
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment