import java.util.Scanner;
/**
*
* @author DAM112
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int[] anArray;
int [] aArray;
aArray = new int[32678];
int num, cont, cont1, raiz, cont2 , cont3 , cont4=0, cont5=0;
boolean primo;
Scanner leer = new Scanner(System.in);
do {
num = leer.nextInt();
if (num != 0) {
aArray[cont4] = num;
cont4++;
}
} while (num != 0);
do {
cont1=0;
cont2=0;
cont3 = 0;
for (int i = 1; i < aArray[cont5]; i++) {
primo = true;
cont = 2;
raiz = (int) Math.sqrt(i);
while (primo && (cont <= raiz)) {
if (i % cont == 0) {
primo = false;
} else {
++cont;
}
}
if (primo == true) {
cont2 = cont2 + 1;
}
}
anArray = new int[cont2];
for (int i = 1; i < aArray[cont5]; i++) {
primo = true;
cont = 2;
raiz = (int) Math.sqrt(i);
while (primo && (cont <= raiz)) {
if (i % cont == 0) {
primo = false;
} else {
++cont;
}
}
if (primo == true) {
anArray[cont3] = i;
cont3++;
}
}
for (int i = 1; i < anArray.length; i++) {
for (int j = 1; j < anArray.length; j++) {
if (anArray[i] + anArray[j] == aArray[cont5]) {
if (anArray[i] == anArray[j]) {
cont1++;
}
cont1++;
}
}
}
System.out.println("" + cont1 / 2);
cont5++;
} while (cont5 != cont4);
}
}
/**
*
* @author DAM112
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
int[] anArray;
int [] aArray;
aArray = new int[32678];
int num, cont, cont1, raiz, cont2 , cont3 , cont4=0, cont5=0;
boolean primo;
Scanner leer = new Scanner(System.in);
do {
num = leer.nextInt();
if (num != 0) {
aArray[cont4] = num;
cont4++;
}
} while (num != 0);
do {
cont1=0;
cont2=0;
cont3 = 0;
for (int i = 1; i < aArray[cont5]; i++) {
primo = true;
cont = 2;
raiz = (int) Math.sqrt(i);
while (primo && (cont <= raiz)) {
if (i % cont == 0) {
primo = false;
} else {
++cont;
}
}
if (primo == true) {
cont2 = cont2 + 1;
}
}
anArray = new int[cont2];
for (int i = 1; i < aArray[cont5]; i++) {
primo = true;
cont = 2;
raiz = (int) Math.sqrt(i);
while (primo && (cont <= raiz)) {
if (i % cont == 0) {
primo = false;
} else {
++cont;
}
}
if (primo == true) {
anArray[cont3] = i;
cont3++;
}
}
for (int i = 1; i < anArray.length; i++) {
for (int j = 1; j < anArray.length; j++) {
if (anArray[i] + anArray[j] == aArray[cont5]) {
if (anArray[i] == anArray[j]) {
cont1++;
}
cont1++;
}
}
}
System.out.println("" + cont1 / 2);
cont5++;
} while (cont5 != cont4);
}
}
No hay comentarios:
Publicar un comentario