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 <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 <deque>
#include <complex>
#include <stack>
#include <queue>
#include <cstdio>
//#include <cctype>
#include <cstring>
//#include <ctime>
#include <iterator>
#include <bitset>
//#include <numeric>
//#include <list>
//#include <iomanip>

#if __cplusplus >= 201103L
#include <array>
#include <tuple>
#include <initializer_list>
#include <unordered_set>
#include <unordered_map>
#include <forward_list>

#define cauto const auto&
#else

#endif

using namespace std;


namespace{
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;

#define VV(T) vector<vector< T > >

template <class T>
void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
    v.assign(a, vector<T>(b, t));
}

template <class F, class T>
void convert(const F &f, T &t){
    stringstream ss;
    ss << f;
    ss >> t;
}


#define reep(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) reep((i),0,(n))
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define F first
#define S second
#define mkp make_pair
#define RALL(v) (v).rbegin(),(v).rend()


#define MOD 1000000007LL
#define EPS 1e-8
static const int INF=1<<24;
bool prime[1100100];
void mainmain(){
	int n;
	rep(i,1100100) prime[i]=true;
	rep(i,2) prime[i]=false;
	for(int i=2;i*i<1100100;i++){
		if(prime[i]){
			for(int j=i*i;j<1100100;j+=i){
				prime[j]=false;
			}
		}
	}
	while(cin>>n,n){
		int ans=prime[n-2];
		for(int i=3;i*2<=n;i+=2){
			if(prime[i]&&prime[n-i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}



}
main() try{
    mainmain();
}
catch(...){
}

C++: 
#include<iostream>
#include<fstream>
#include<sstream>
#include<cstdio>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
#include<cstdlib>
#include<climits>
#include<utility>
#include<cctype>
using namespace std;

#define ull unsigned long long
#define stt(it,order) sort(it.begin(),it.end(),order)
#define STT(it,n,order) sort(it,it+n,order)
#define st(it) sort(it.begin(),it.end())
#define ST(it,n) sort(it,it+n)
#define ll long long
#define rep(i,j) for(int i=0;i<j;++i)
#define loop(i,a,j) for(int i=a;i<j;++i)
#define mpi(it,table,T,E) for(map<T,E>::iterator it = table.begin();it!=table.end();++it)
#define PI 3.141592654
#define pb(v,e) v.push_back(e)
#define ms(a,v) memset(a,v,sizeof(a))
#define cp(a,b,n) rep(i,n)a[i] = b[i]
#define pi(a) printf("%d\n",a)
#define ps(a) printf("%s\n",a)
#define si(a) scanf("%d",&a)
#define print_int_matrix(mat,n) rep(i,n-1){printf("%d ",mat[i]);}printf("%d\n",mat[n-1]);
#define print_string_matrix(mat,n) rep(i,n-1){printf("%s ",mat[i]);}printf("%s\n",mat[n-1]);
#define mkp(a,b) make_pair(a,b)
#define fnd(table,e) (find(table.begin(),table.end(),e) != table.end())

//TYPOS DE DATOS PERSONALES
typedef unsigned int _set;
typedef unsigned long _lset;
typedef pair<int,int> pii;

string sint(int i){
   stringstream buf;
   buf<<i;
   return buf.str();
}

/*
ifstream fin("input.txt");
ofstream fout("output.txt");
#define cin fin
#define cout fout
*/

int dx[] = {-1,0,0,1};
int dy[] = {0,-1,1,0};
int dx8[] = {-1,-1,-1,0,0,1,1,1};
int dy8[] = {-1,0,1,-1,1,-1,0,1};

#define N 1000002
bool is_prime[N];
vector<int> primes;

void sieve(){
   ms(is_prime,1);
   is_prime[0] = is_prime[1] = false;
   for(int x=2;x<N;++x){
      if( is_prime[x] ){
         pb(primes,x);
         for(int i = x+x;i<N;i+=x){
            is_prime[i] = false;
         }
              
      }
   }
}

int main(){
   sieve();
   int n;
   while( si(n) != EOF , n){
      int t = 0;
      rep(i,primes.size()){
         if( primes[i] > n/2 )break;
         if( is_prime[ n - primes[i] ] )t++;
      }
      printf("%d\n",t);
   }
   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;

bool isPrime[1000000];
int main()
{
	fill(isPrime, isPrime+1000000, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i < 1000000; ++i)
	{
		if (isPrime[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				isPrime[j] = false;
		}
	}

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

	return 0;
}

C++: #include<cstdio>
#define N 1000000

using namespace std;

int main(void){
	int i,j;
	int num[N+1];
	int n,count;

	num[0]=0;
	num[1]=0;
	for(i=2;i<N+1;i++)
		num[i]=1;
	for(i=2;i<N+1;i++)
		if(num[i])
			for(j=i+i;j<=N;j+=i)
				num[j]=0;

	for(;;){
		scanf("%d",&n);
		if(!n)
			break;

		count=0;
		for(i=2;i<=n/2;i++)
			if(num[i] && num[n-i])
				count++;
		
		printf("%d\n",count);
	}

	return 0;
}

C++: #include <cstdio>
 
#define MAX 1000000
 
bool prime[MAX];
 
void make()
{
    fill(prime, prime + MAX, true);
 
    prime[0] = prime[1] = false;
    for (int i = 2; i*i < MAX; i++) { 
	if (prime[i]) {
	    for (int j = 2*i; j < MAX; j += i) {
		prime[j] = false;
	    }
	}
    }
}
 
int main()
{
    make();
    int n;
    while (scanf("%d", &n), n) {
	int cnt = 0;
	for (int i = 2; i+i <= n; i++) {
	    if (prime[i] && prime[n-i]) {
		cnt++;
	    }
	} 
	printf("%d\n", cnt);
    }
    return 0;
}

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

int main(){
	bool is_prime[1000000]={};
	vector<int> prime;
	for(int i=2;i<1000000;i++){
		if(is_prime[i]) continue;
		prime.push_back(i);
		for(int j=1;i*j<1000000;j++){
			is_prime[i*j] = true;
		}
	}

	int N;
	while(cin>>N,N){
		int ans = 0;
		bool used[1000000] = {};
		for(int i=0; i<prime.size() && prime[i]<N; i++){
			if(used[prime[i]]) continue;
			vector<int>::iterator itr = lower_bound(prime.begin(),prime.end(),N-prime[i]);
			if(itr != prime.end() && prime[i]+*itr == N){
				used[prime[i]] = used[*itr] = true; ans++;
			}
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;


int isPrime(int in) {
  int flag = 1;
  if(in == 1) return 0;
  for(int i = 2;i * i <= in;i++){
    if(in % i == 0) flag = 0;
  }
  return flag;
}


int main(){

  long long n,a,ans = 0;

  while(true){

  cin >> n;
  if(n == 0) break;
  for(long long i = 2;i <=  n / 2;i++){
    if(isPrime(i) == 1) {
      a = n - i;
      if(isPrime(a) == 1){
	ans++;
	//	cout << a <<  ' ' << i << endl;
      }
    }
  }
  cout << ans << endl;
  ans = 0;
  }
}