Go: package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
	)

var scanner = bufio.NewScanner(os.Stdin)

func main() {
	prime := make([]int, 1000001)
	prime[0], prime[1] = -1, -1
	for i := 2; i < 1000001; i++ {
		if prime[i] != -1 {
			prime[i] = 1 // i means "prime"
			for j := i+i; j < 1000001; j += i {
				prime[j] = -1 // -1 means "not prime"
			}
		}
	}
	for scanner.Scan() {
		ret := 0
		a, _ := strconv.Atoi(scanner.Text())
		if a == 0 {
			break
		}
		for i := 1; i <= a/2; i++ {
			if prime[i] == 1 && prime[a-i] == 1 {
				ret++
			}
		}
		fmt.Println(ret)
	}
}

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0185

"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline


def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    nums = [x for x in range(2, limit+1)]
    while nums[0] <= x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x % current_prime != 0]
    primes.extend(nums)
    return primes


def main(args):
    primes = create_prime_list(1000000)

    while True:
        n = int(input())
        if n == 0:
            break

        ans = 0                 #  ????????????????????????????????°
        for i in range(n):
            a = primes[i]
            if a > n/2:
                break
            i = bisect_left(primes, n - a)
            if i != len(primes) and primes[i] == n-a:
                ans += 1
        print(ans)



if __name__ == '__main__':
    main(sys.argv[1:])

Python: MN = 100000
prime = []
mem = [False] * 2 + [True] * MN
for i in range(2, MN):
  if not mem[i]:
    continue
  prime.append(i)
  for j in range(i + i, MN, i):
    mem[j] = False

while True:
  N, ans = input(), 0
  if not N:
    break

  for p in prime:
    if p > N / 2:
      break
    if mem[N - p]:
      ans += 1
  print(ans)

Python: # -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0185

"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline


def create_prime_list(limit):
    """ ??¨??????????????????????????§limit?????§????´???°?????????????±???????
    https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9
    """
    x = limit**0.5
    primes = []
    nums = [x for x in range(2, limit+1)]
    while nums[0] <= x:
        primes.append(nums[0])
        current_prime = nums[0]
        nums = [x for x in nums if x % current_prime != 0]
    primes.extend(nums)
    return primes


def main(args):
    primes = create_prime_list(500000)

    while True:
        # n = 98792
        n = int(input())
        if n == 0:
            break

        ans = 0                 #  ????????????????????????????????°
        for i in range(n):
            a = primes[i]
            if a > n/2:
                break
            i = bisect_left(primes, n - a)
            if i != len(primes) and primes[i] == n-a:
                ans += 1
        print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])

Python: from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst, len_prime):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if i < len_prime and prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)
len_prime = len(prime_lst)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst, len_prime))

Python: MN = 1000000
prime = []
mem = [False] * 2 + [True] * MN
for i in range(2, MN):
  if not mem[i]:
    continue
  prime.append(i)
  for j in range(i + i, MN, i):
    mem[j] = False

while True:
  N, ans = input(), 0
  if not N:
    break

  for p in prime:
    if p > N / 2:
      break
    if mem[N - p]:
      ans += 1
  print(ans)

Python: import sys
readline = sys.stdin.readline
write = sys.stdout.write

M = 1000000
sq = int(M**.5)
pl = []
p = [1]*(M+1)
p[0] = p[1] = 0
for x in range(2, sq+1):
    if p[x]:
        for y in range(x*x, M+1, x):
            p[y] = 0
        pl.append(x)
for x in range(sq+1, M+1):
    if p[x]:
        pl.append(x)

def solve():
    N = int(readline())
    if N == 0:
        return False
    ans = 0
    N2 = N//2
    for x in pl:
        if N2 < x:
            break
        if p[N-x]:
            ans += 1
    write("%d\n" % ans)
    return True
while solve():
    ...

Python: import sys
def main():
    for line in sys.stdin:
        n = int(line)
        if n == 0:
            break
        else:
            hoge = [i for i in range(2, n)]
            fuga = [2]
            for i in range(1, len(hoge)):
                cnt = 0
                for j in range(i):
                    if hoge[i] % hoge[j] == 0:
                        break
                    else:
                        cnt += 1
                if cnt == i:
                    fuga.append(hoge[i])

            ans = 0
            for i in range(len(fuga) - 1):
                for j in range(i, len(fuga)):
                    if fuga[i] + fuga[j] == n:
                        ans += 1
                    else:
                        pass

            print(ans)

if __name__ == "__main__":
    main()

Python: from bisect import bisect_left as bl
def primes(n):
  tf = [True] * (n + 1)
  tf[0] = tf[1] = False
  for i in range(2, int(n ** (1 / 2) + 1)):
    if tf[i]:
      for j in range(i ** 2, n + 1, i):
        tf[j] = False
  return [i for i in range(n + 1) if tf[i]]

def search_pair(x, prime_lst):
  cnt = 0
  for prime in prime_lst:
    if prime > x // 2:
      break
    i = bl(prime_lst, x - prime)
    if prime_lst[i] == x - prime:
      cnt += 1
  return cnt

prime_lst = primes(1000000)

while True:
  n = int(input())
  if n == 0:
    break
  print(search_pair(n, prime_lst))

Python: import bisect
primes = [0, 0] + [1]*999999
for i in range(2, 1001):
    if primes[i]:
        for j in range(i*i, 1000001, i):
            primes[j] = 0

prime_value = [i for i in range(len(primes)) if primes[i]]
while True:
    n = int(input())
    if n == 0:
        break
    x = bisect.bisect_right(prime_value, n//2)
    print(sum(1 for p in prime_value[:x] if primes[n-p]))

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <fstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
typedef long long LL;
typedef pair<int, int> P;
static const double EPS = 1e-5;

#define FOR(i,k,n) for (int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
const int MAX = 1000001;
int main(void){
  bool prime[MAX];
  vector<int> p;
  FOR(i,2,MAX) prime[i]=true;
  FOR(i,2,MAX){
    if(prime[i]){
      p.push_back(i);
      for(int k=2; i*k<=MAX; k++){
        prime[i*k]=false;
      }
    }
  }
  int n;
  while(cin>>n){
    if(n==0) break;
    int count=0;
    for(int i=0; i<p.size()&&2*p[i]<=n; i++){
      if(prime[n-p[i]]) count++;
    }
    cout<<count<<endl;
  }
  return 0;
}