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)
	}
}

C++: #include <iostream>
#include <vector>
using namespace std;

#define MAX 1000000
typedef long long ll;

void ESieve(vector<bool> &isPrime) {
  isPrime.assign(MAX + 1, true);
  isPrime[0] = isPrime[1] = false;
  for(int i=2; (ll)i*i<=MAX; i++) {
    if(isPrime[i]) {
      for(int j=2*i; j<=MAX; j+=i) {
	isPrime[j] = false;
      }
    }
  }
}

int main() {
  
  vector<bool> isPrime;
  ESieve(isPrime);

  int n;
  while(cin>>n, n) {
    int res = 0;
    for(int i=2; i <= n/2; i++) {
      if(isPrime[i] && isPrime[n-i]) {
	res ++;
      }
    }
    cout << res << endl;
  }
  
  return 0;
}

C++: // #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef vector<pair<int, int> > VPII;

#define MP make_pair
#define fastIO	cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (未test)
// #define FOREACH_IT(it,c)	for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(), c_end=c.end(); it!=c_end; ++it)

// ------------------- include, typedef, define END. -------------------

bool sosuuCheck(int n){
	if (n % 2 == 0)	return false;
	for (int i = 3;i<=sqrt((double)n);i+=2){
		if (n%i == 0)	return false;
	}
	return true;
}

int solve(int n){
	int ans = 0;
	for (int i = 3; i <= n / 2; i += 2){
		if (sosuuCheck(i)){
			if (sosuuCheck(n - i)){
				ans++;
			}
		}
	}
	return ans;
}

int main(){
	fastIO;
	int n;

	while (cin >> n, n){
		cout << solve(n) << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAXN = 1000 * 1000 + 20;

bool p[MAXN];

int main()
{
    p[0] = p[1] = 1;
    REP(MAXN)if(!p[i])for(int j= i*2;j<MAXN;j+=i)p[j] = 1;

    int n;
    while(cin >> n && n)
    {
        int ans = 0;
     
        for(int i=3;i<= n/2 ;i+=2)
        {
            if((!p[i]) && (!p[n - i])) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include<stdio.h>

#define NN 1000001;

int main(){

bool f[(1000001)];
int c=0,x;

for(int i=3;i<1000001;i+=2)
f[i]=true;

for(int i=3;i<1000001;i+=2)
for(int j=3;j*j<=i;j+=2)
if(i%j==0)f[i]=false;

while(1){
scanf("%d",&x);if(x==0)break;
for(int i=3;i<x;i+=2)
for(int j=x-1;j>=i;j-=2)
	if((f[i]==true&&f[j]==true)&&i+j==x){printf("%d+%d\n",i,j);c++;}

printf("%d\n",c);
c=0;
}
return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

bool sieve[1000001];
vector<UL> P;

int main() {
	rep(i, 1000001) sieve[i] = true;
	sieve[0] = sieve[1] = false;
	for (UL p = 2; p <= 1000000; p++) {
		if (!sieve[p]) continue;
		P.push_back(p);
		if (p <= 1000) for (UL j = p * p; j <= 1000000; j += p)
			sieve[j] = false;
	}

	UL N;
	while (true) {
		cin >> N;
		if (N == 0) break;
		UL ans = 0;
		rep(i, P.size()) {
			UL p = P[i];
			if (p + p > N) break;
			if (sieve[N - p]) ans++;
		}
		cout << ans << "\n";
	}
	cout << flush;

	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[1000001];
    for(int i=2;i<1000001;i++)prime[i]=true;
    for(int i=2;i<=sqrt(1000000);i++){
        if(prime[i]==true){
            for(int j=i+i;j<1000001;j+=i)prime[j]=false;
        }
    }
    int n,cou=0;
    while(cin>>n&&n!=0){
        for(int i=2;i<=n/2;i++)if(prime[i]==true&&prime[n-i]==true)cou++;
        cout<<cou<<endl;
    cou=0;
    }
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 1<<30

vector<int> eratosthenes(int n) {
  vector<int> v(n);
  for (int i=2; i<n; i++) v[i] = i;
  for (int i=2; i*i<n; i++)
    if (v[i])
      for (int j=i*i; j<n; j+=i)
        v[j] = 0;
//  v.erase(remove(ALL(v),0),v.end()); // ツつアツつアツづーツづつつッツづェツづ篠素ツ青板δ環スツト
  return v;
}

int main() {
  vector<int> table = eratosthenes(1000000);
  vector<int> prime = table;
  prime.erase(remove(ALL(prime),0),prime.end()); // ツつアツつアツづーツづつつッツづェツづ篠素ツ青板δ環スツト
 
  int n;
  while(cin >> n, n) {
    int res = 0;
    for (int i=0; prime[i] <= n/2; ++i) {
      if (table[n - prime[i]])
        res++;
    }
    cout << res << endl;
  }
}

C++: #include <iostream>
#include <algorithm>

using namespace std;

int main()
{
	int n, c, p=0;
	bool pr[1000001];
	fill(pr, pr+1000001, true);
	pr[0] = pr[1] = false;
	
	for(int i = 2; i < 1000001; i++){
		if(pr[i]){
			for(int j = 2*i; j < 1000001; j+=i){
				pr[j] = false;
			}
		}
	}

	while(1){
		cin >> n;
		if(n == 0){
			break;
		}
		c = 0;
		for(int i = 2; i <= n/2; i++){
			if(pr[i]){
				if(pr[n-i]){
					c++;
				}
			}
		}
		cout << c << endl;
	}
	
	return 0;
}