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<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<functional>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cassert>
#include<ctime>
using namespace std;

#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define absd(x) (x<0?-(x):x)
#define pow2(x) ((x)*(x))
#define rep(i,n) for(int i=0; i<n; ++i)
#define repr(i,n) for(int i=n-1; i>=0; --i)
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define replr(i,s,n) for(int i=n; i>=s; --i)
#define repf(i,s,n,j) for(int i=s; i<=n; i+=j)
#define repe(e,obj) for(auto e : obj)

#define SP << " " <<
#define COL << " : " <<
#define COM << ", " <<
#define ARR << " -> " <<
#define PNT(STR) cout << STR << endl
#define POS(X,Y) "(" << X << ", " << Y << ")"
#define DEB(A) " (" << #A << ") " << A
#define DEBREP(i,n,val) for(int i=0; i<n; ++i) cout << val << " "; cout << endl
#define ALL(V) (V).begin(), (V).end()
#define INF 1000000007
#define INFLL 1000000000000000007LL
#define EPS 1e-9

typedef unsigned int uint;
typedef unsigned long ulong;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define P_TYPE int
typedef pair<P_TYPE, P_TYPE> P;
typedef pair<P, P_TYPE> PI;
typedef pair<P_TYPE, P> IP;
typedef pair<P, P> PP;
typedef priority_queue<P, vector<P>, greater<P> > pvqueue;

#define N 1000005

int np[N+1];

int main() {
  np[0] = np[1] = 1;
  repl(i, 2, 1000) {
    if(!np[i]) {
      repf(j, i*i, N, i) {
        np[j] = 1;
      }
    }
  }
  int n;
  while(cin >> n && n) {
    int ans = 0;
    repl(x, 2, n/2) {
      if(!np[x] && !np[n-x]) {
        ++ans;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)

#define MAX 1000000
vector<bool> prime(MAX+1,true);
void init(){
	prime[0] = prime[1] = 0;
	for(int i=2;i*i<=MAX;i++){
		if(prime[i]){
			for(int j=i*i;j<=MAX;j+=i){
				prime[j] = false;
			}
		}
	}
}

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

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

#define MAX (1000000 / 2) + 100

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

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

int p[1000000];
int main()
{
	for (int i = 2; i < 1000; ++i)
	{
		if (!p[i])
		{
			for (int j = i+i; j < 1000000; j += i)
				p[j] = 1;
		}
	}

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 3; i <= n/2; ++i)
			(p[i] | p[n-i]) || ++ans;
		printf("%d\n", ans);
	}

	return 0;
}

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

#define MAX 1000001

int main(void)
{
	int i, j;
	bool p[MAX];
	
	for (i = 0; i < MAX; i++){
		p[i] = true;
	}
	for (i = 2; (i * i) < MAX; i++){
		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 * 2) <= n; i++){
			if (p[i] && p[n - i]) res++;
		}
		cout << res << endl;
	}
	
	return 0;
}

C++: #include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
bool prime[1000010];
void sieve(){
	for(int i =1;i <=1000000;i++){
		prime[i]=true;
	}
	prime[1]=false;
	for(int i =2;i*i<=1000000;i++){
		if(prime[i]){
			for(int j =i*i;j<=1000000;j+=i){
				prime[j]=false;
			}
		}
	}
}
int main(){
	int n;
	sieve();
	while(cin>>n,n){
		int ans = 0;
		for(int i =2;i <=n/2;i++){
			if(prime[i]&&prime[n-i]){
				ans++;
			}
			
		}
		cout <<ans<<endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define N 1000005
using namespace std;
bool prime[N];
set<int> p;
int n,ans;


int main(){
  for(int i=0;i<N;i++)prime[i]=true;
  prime[0]=prime[1]=false;
  for(int i=0;i*i<N;i++){
    if(!prime[i])continue;
    for(int j=i*2;j<N;j+=i)prime[j]=false;
  }
  for(int i=0;i<N;i++)
    if(prime[i])p.insert(i);
  while(1){
    cin>>n;
    if(!n)break;
    ans=0;
    set<int>::iterator ite;
    for(ite=p.begin();ite!=p.end();ite++){
      int key=n-(*ite);
      if((*ite)>key)continue;
      if(p.count(key))ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

bool is_prime[10000001];
vector<int> prime;

void sieve(){
	fill(is_prime,is_prime+10000001,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<=10000000; ++i){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j=2; i*j<=10000000; ++j){
				is_prime[i*j]=false;
			}
		}
	}
}

int main(){
	sieve();
	int N;
	while(cin >> N&&N){
		long long int ans=0;
		for(int i=0; i<=N/2; ++i){
			if(is_prime[i]&&binary_search(prime.begin(),prime.end(),N-i)){
				//cout << i << endl;
				++ans;
			}
		}
		cout << ans << 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 + 10;

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= 0;i<= n/ 4;i++)
        {
            if(!p[i * 2 + 1] && !p[n - i * 2 - 1]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

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

bool p[1000002];

void mkPrime(void){
	memset(p,true,sizeof(p));
	p[0] = p[1] = false;
	for(int i=0;i<=1000000;i++){
		if(p[i]){
			for(int j=i+i;j<=1000000;j+=i){
				p[j] = false;
			}
		}
	}
}

int main(void){
	int n;
	mkPrime();

	while(cin>>n,n){
		int ans = 0;
		for(int i=0;i<n;i++){
			if(i > n-i) break;
			if(p[i] && p[n-i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}

	return 0;
}