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 <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 < 1000000; ++i)
	{
		if (!p[i])
		{
			for (int j = 2*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 += 2)
			if (!p[i] && !p[n-i])
				++ans;
		printf("%d\n", ans);
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
#include<cmath>
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	int n; while (cin >> n, n) {
		int cnt = 0;
		for (int i = 2; i <= n / 2; i++) {
			if (isprime(i) && isprime(n - i)){cnt++;
		}
		cout << cnt << endl;
	}
}

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

const int LIMIT = 1000001;

int main()
{
	bool* prime = new bool[ LIMIT ]();
	prime[ 0 ] = prime[ 1 ] = true;
	for( int i = 2; i < LIMIT; ++i ){
		if( prime[ i ] ) continue;
		for( int j = i + i; j < LIMIT; j += i ){
			prime[ j ] = true;
		}
	}

	int n;
	while( cin >> n && n ){
		int count = 0;
		for( int i = 0; i < n / 2 + 1; ++i ){
			if( prime[ i ] || prime[ n - i ] ) continue;
			++count;
		}
		cout << count << endl;
	}

	delete[] prime;

	return 0;
}

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

#define MN 500001
bool pr[MN] = {0};

int main()
{
	for(int i=2; i<MN; i++) { pr[i] = 1; }
	for(int i=2; i*i<MN; i++)
	{
		if(pr[i])
		for(int j=i*2; j<MN; j+=i)
		{
			pr[j] = 0;
		}
	}

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

C++: #include <bits/stdc++.h>

using namespace std;

int PrimeNumber[1000001] = {0,0,1,1};

void findPrimeNumber(){
	int limit;
	bool flag;

	for (int i = 5; i < 1000001; i += 2) {
		limit = sqrt(i) + 1;
		flag = true;
		for (int j = 2; j < limit; j++) {
			if (i%j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			PrimeNumber[i] = 1;
		}
	}

	return;
}

int main() {
	int n, rest, sum;

	findPrimeNumber();
	while (cin >> n, n) {
		sum = 0;
		for (int i = 2; i < n; i++) {
			rest = n - i;
			if (i > rest) {
				break;
			}
			if (PrimeNumber[i] == 1 && PrimeNumber[rest] == 1) {
				sum++;
			}
		}
		 
		cout << sum << endl;
	}
	

	return 0;
}

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

int main()
{
  bool pri[1000001];
  vector<int> price;
  fill(pri,pri+1000001,true);
  pri[0]=pri[1]=false;
  for(int i=2;i<1000001;i++)
    {
      if(pri[i]==0)
	continue;
      price.push_back(i);	
      for(int j=i+i;j<1000001;j+=i)
	{
	  pri[j]=false;
	}
    }
  int n;
  for(;cin>>n,n;)
    {     
      int count=0;

      for(int i=0;i<price.size();i++)
	{
	  if(n-price[i]<2)
	    break;
	  if(price[i]>(n-price[i]))
	     break;
	  if(pri[n-price[i]])
	    {
	      count++;
	    }
	}	  
      cout<<count<<endl;
    
    }
 
}

C++: 
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <memory>
#include <string>

#include <algorithm>
#include <complex>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#include <bitset>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
#define strtok_r strtok_s
#endif

#define ITER(c)             __typeof__((c).begin())
#define FOREACH(it, c)      for (ITER(c) it=(c).begin(); it != (c).end(); ++it)
#define RITER(c)            __typeof__((c).rbegin())
#define RFOREACH(it, c)     for (RITER(c) it=(c).rbegin(); it != (c).rend(); ++it)
#define REP(i, n)           REPEAT(i, 0, n)
#define RREP(i, n)          RREPEAT(i, 0, n)
#define REPEAT(i, k, n)     for(int i = (k); i < ((k)+(n)); ++i)
#define RREPEAT(i, k, n)    for(int i = (k)+(n)-1; i >= (k); --i)
#define FROMTO(i,f,t)       for(int i = f; i < t; i++)
#define ALL(c)              (c).begin(), (c).end()
#define LLPOW(p1,p2)        ((ll)pow((double)(p1), (int)p2))
#define ESIZEOF(A)          (sizeof(A)/sizeof((A)[0]))
#define CIN_NO_SYNC         do { cin.tie(0); ios_base::sync_with_stdio(false); } while(0)
#define GETSTR(p)           fgets((p), sizeof(p), stdin)
#define CHOMP(p)            do{ char *_q = (p) + strlen(p)-1; if(*_q == '\n' || *_q == '\r') *_q = 0; } while(0)
#define FILL(m,v)           memset(m, v, sizeof(m))
#define mp                  make_pair
#define pb                  push_back
template<class _T> _T MAX(_T p1,_T p2){return (p1>p2)?p1:p2;} 
template<class _T> _T MIN(_T p1,_T p2){return (p1<p2)?p1:p2;} 
template <class _Tv> inline string join(const _Tv &v,string sep=" "){
    ostringstream s;FOREACH(it,v){if(it!=v.begin())s<<sep;s<<*it;};return s.str();
}

typedef long long ll;
typedef unsigned long long ull;
typedef double D;
typedef complex<D> P;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define X real()
#define Y imag()
#define EPS (1e-9)
#define DEQ(p1,p2) (abs((p1)-(p2)) < EPS)

#ifdef _DEBUG
template<class _Tv> inline void _prfe(const char *_n,const _Tv _c,bool _p=false){
    ITER(_c) _it=_c.begin();
    if(_p){cout<<_n<<" = ["<<endl;for(;_it!=_c.end();++_it)cout<<"    "<<*_it<<endl;cout<<"]"<<endl; }
    else{cout<<_n<<" = [ ";if(_c.size()){cout<<*_it++;for(;_it!=_c.end();++_it)cout<<", "<<*_it;}cout<<" ]"<<endl; }
}
ostream &operator<<(ostream &os, const pair<int,int> &p){return(os<<"("<<p.first<<","<<p.second<<")");}
#define pf printf
#define pr(n) do{cout<<#n" = "<<(n)<<endl;}while(0)
#define prfe(n) _prfe(#n, n)
#define prfep(n) _prfe(#n, n, true)
#define dbgchk(n) do{if(n)throw;}while(0)
#else
#define pf(...) /* */
#define pr(...) /* */
#define prfe(...) /* */
#define prfep(...) /* */
#define dbgchk(...) /* */
#endif

const int LIM = 1000000+1;
bool prime[LIM];
vector<int> vprime;

int main(){
    prime[2] = true;
    vprime.pb(2);
    for(int i = 3; i < LIM; i+=2) prime[i] = true;
    for(int i = 3; i < LIM; i+=2){
        if(!prime[i]) continue;
        for(int j = i*3; j < LIM; j+=i*2) prime[j] = false;
        vprime.pb(i);
    }

    int n;
    while(cin >> n && n){
        int c = 0;
        FOREACH(it,vprime){
            if(n/2 < *it) break;
            if(prime[n-*it]) c++;
        }
        cout << c << endl;
    }
    return 0;
}