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 <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


ll l=10000100;

vi v(l,1);
   

int main(){
	v[0]=0;
	v[1]=0;
	for(int i=2; i<l; i++){
		if(v[i]==1){
			for(int j=2; j<l/i; j++){
				v[i*j]=0;
			}
		}
	}
	int n,ans;
	while(cin>>n && n>0){
		ans=0;
		for(int i=2; i<=n/2; i++){
			if(v[i]==1 && v[n-i]==1)ans++;
		}
		cout<<ans<<endl;
	}
}

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, set<int> &sosuuList){
	int ans = 0;
	foreach_it(set<int>, it, sosuuList){
		if ((*it) > n / 2)	break;
		if (sosuuList.find(n - (*it)) != sosuuList.end())
			ans++;
	}
	/*for (int i = 3; i <= n / 2; i += 2){
		if (sosuuCheck(i)){
			if (sosuuCheck(n - i)){
				ans++;
			}
		}
	}*/
	return ans;
}

int main(){
	// 以下URLよりも速いかどうか気になったのでこのコードを書いた.
	// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1136634#1
	fastIO;
	int n;
	set<int> sosuuList;
	sosuuList.insert(2);
	sosuuList.insert(3);
	for (int i = 5; i <= 1000000; i += 2){
		if (sosuuCheck(i))
			sosuuList.insert(i);
	}

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

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

#define MAX 1000001

int main(){
  bool p[MAX];
  memset(p, 1, sizeof(p));
  p[1] = p[0] = 0;
  for(int i = 0 ; i < MAX ; i++){
    if(p[i]){
      for(int j = 2 * i ; j < MAX ; j += i){
	p[j] = 0;
      }
    }
  }

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

C++: #include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
typedef complex<double> P;
const int MAX_N = 1000001;

bool isp[MAX_N];

void make_prime(){
  REP(i, MAX_N) isp[i] = true;
  isp[0] = isp[1] = false;
  FOR(i, 2, MAX_N){
    if(!isp[i]) continue;
    for(int j = i + i; j < MAX_N; j += i) isp[j] = false;
  }
}

int main() {
  make_prime();
  int N;
  while(cin >>N && N){
    int cnt = 0;
    FOR(i, 2, N / 2) if(isp[i] && isp[N - i]) ++cnt;
    if(isp[N / 2]) ++cnt;
    cout <<cnt <<endl;
  }
  return 0;
}

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

#define MAX 1000001

int main(void)
{
	int i, j;
	bool p[MAX];
	for (i = 0; i < MAX; i++){
		p[i] = true;
	}
	p[0] = p[1] = false;
	p[2] = true;
	for (i = 3; i < MAX; i += 2){
		if (p[i]){
			for (j = i * 2; j < MAX; j += i){
				p[j] = false;
			}
		}
	}
	
	int n;
	while (cin >> n, n){
		int res = 0;
		for (i = 2; i <= n / 2; i++){
			if (p[i] && p[n - i]) res++;
		}
		cout << res << endl;
	}
	
	return 0;
}

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

int main (){

	int arr[1000000];
	int N=1000000;

		for(int i = 0; i < N; i++){
			arr[i] = 1;
		}
		for(int i = 2; i < sqrt(N); i++){
			if(arr[i]){
				for(int j = 0; i * (j + 2) < N; j++){
					arr[i *(j + 2)] = 0;
				}
			}
		}
	
	while(1){
		int n,a=0;
		cin >> n;
		if(n==0)
			break;

		
		for(int i = 0; i <= n/2; i++){
			if(arr[i]&&arr[n-i])
				a++;
		}

		cout << a << endl;
	}
}

C++: // 2011/02/20 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prime[], int n)
{
	if(n>=1)
		prime[0] = false;
	if(n>=2)
		prime[1] = false;

	for(int i=2; i<n; i++)
		prime[i] = true;

	for(int i=2; i<n; i++){
		if(!prime[i])
			continue;
		for(int j=i+i; j<n; j+=i)
			prime[j] = false;
		if(n<i*i)
			return;
	}
}

int main()
{
	bool prime[1000001];
	eratos(prime, 1000001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt = 0;
		for(int p=2; p<=n-p; p++)
			if(prime[p]&&prime[n-p])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

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

long long int a[1000000] = {0},n;

int main(){

  for(int i=2;i*i<=1000000;i++){
    if(a[i] == 0){
      for(int j=i+i;j<=1000000;j+=i) a[j] = 1;
    }
  }

  while(cin >> n, n){

    int ans = 0;

    for(int i=2;i<=n/2;i++){
      if(a[i] == 0 && a[n - i] == 0) ans++;
    }

    cout << ans << endl;

  }
}

C++: #include<iostream>
using namespace std;
int main(){
long n,c,*p,i,j;
n=1000000;
p=new long[1000001];
for(p[1]=0,i=3;i<=n;i+=2)p[i]=1;
for(p[2]=1,i=4;i<=n;i+=2)p[i]=0;
j=3;
while(j*j<=n){
for(i=j;i<=n/j;i+=2)p[i*j]=0;
j++;
while(p[j]==0)j++;
}
while(cin>>n){
if(n==0)break;
for(c=0,i=3;i*2<=n;i++){
if(p[i]==1&&p[n-i]==1)c++;
}
cout<<c<<endl;
}
return 0;
}

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

#define sz size()

string MakeTable(int n){
  int i,j;
  string p = "001";
  while(p.sz<=n)p += "10";
  i = 3;
  while(i*i<n){
    for(j=3*i;j<n;j+=2*i)p[j]='0';
    do{i+=2;}while(p[i]-'1');
  }
  return p;
}

int main(){
  string p;
  int n,ans;

  while(1){
    cin >> n;
    if(!n)break;

    p = MakeTable(n);

    if(p[n-2]=='1')ans = 1;
    else ans = 0;

    for(int i=3;i<=n/2;i+=2){
      if(p[i]=='1' && p[n-i]=='1')ans++;
    }

    cout << ans << endl;
  }
}