1. JAVA, Andreas Kunft


/*

 * ACM Programming Contest

 * Problem:     686 (Goldbach's Conjecture (II))

 * Status:        Accepted

 * Language:    JAVA

 * Runtime:        0.130

 * Date:        2009-03-18 14:16:57

 * Author:        Andreas Kunft

 */



import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;



public class Main

{

    public static void main(String... args) throws IOException

    {

        BufferedReader reader = new BufferedReader(new InputStreamReader(

                System.in));

        String line = reader.readLine();

        while (!line.equals("0"))

        {

            int number = Integer.parseInt(line);

            if (number == 4)

                System.out.println(1);

            else

            {

                int count = 0;

                for (int i = 3; i <= number / 2; i += 2)

                {

                    if (prim(i) && prim(number - i))

                        count++;

                }

                System.out.println(count);

            }

            line = reader.readLine();

        }

    }



    private static boolean prim(int n)

    {

        if (n == 2)

            return true;

        for (int i = 3; i <= Math.sqrt(n); i += 2)

            if (n % i == 0)

                return false;

        return true;

    }

}