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<stdio.h>
int main()
{
	static char prime[1000002];
	int i,j,k,n;
	for(i=1;i<=1000000;i+=2){
		prime[i]=1;
	}
	prime[1]=0;
	prime[2]=1;
	for(i=1;i<=100000;i+=2){
		if(prime[i]==1){
			for(j=3;i*j<=100000;j+=2){
				prime[i*j]=0;
			}
		}
	}
	while(1){k=0;
		scanf("%d",&n);
		if(n==0){
			break;
		}
		for(i=2;i<=n/2;i++){
			if(prime[i]&&prime[n-i]){
				k++;
			}
		}

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

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

inline void prime(int *p, int n){

  fill(p, p+n, 1);

  p[0] = 0;
  p[1] = 0;
  for(int i=2; i<=n; i++){
    for(int j=2; i*j<=n; j++){
      p[i*j] = 0;
    }
  }

}

int main(){

  int p[1000000], cnt, n;

  prime(p, 1000000); 
  
  while(cin >> n){
    if(n == 0) break;
    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++: #define _USE_MATH_DEFINES
#define INF 10000000
#include <iostream>
#include <sstream>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double eps = 1e-8;

int main(){

	bool table[1000001];
	fill((bool*)table,(bool*)table+1000001,true);

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

	int n;
	while(~scanf("%d",&n)){
		if(n==0) break;

		int res=0;
		for(int i=n,j=0;j<n/2;j++,i--){
			if(table[i] && table[j]) res++;
		}

		printf("%d\n",res);
	}
}

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(){

  int n,a,ans = 0;

  while(true){

  cin >> n;
  if(n == 0) break;
  for(int 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;
  }
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 10007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0,  1, -1,  1, -1 };
static const int dy[] = { 0, -1, 0, 1 , 1,  1, -1, -1 };

VI pm;
int n;

int main() {
	pm.push_back( 2 );
	for ( int i = 3; i < 1000000; i += 2 ) {
		bool can_add = true;
		for ( int j = 0; j < pm.size() && sq(pm[j]) <= i; j++ ) {
			if ( i % pm[ j ] == 0 ) {
				can_add = false;
				break;
			}
		}
		if ( can_add ) {
			pm.push_back( i );
		}
	}
	while ( ~scanf("%d", &n) && n ) {
		int ans = 0;
		for ( int i = 0; i < pm.size() && pm[i] <= n / 2; i++ ) {
			ans += binary_search( pm.begin(), pm.end(), n - pm[ i ] );
		}
		printf( "%d\n", ans );
	}
	return 0;
}

C++: #include <cstdio>

#define MAX 1000000

bool prime[MAX];

void make(){
  for(int i = 0 ; i < MAX ; i++){
    prime[i] = 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++: #define _USE_MATH_DEFINES
#include "bits/stdc++.h"
using namespace std;

//#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
const double EPS = 1e-10;

signed main() {
	int N(1001000);
	vector<bool>p(N, true); p[0] = p[1] = false;
	for (int i = 2; i*i <= N; i++) {
		if (p[i]) {
			for (int j = i + i; j < N; j += i)p[j] = false;
		}
	}
	int n;
	while (cin >> n, n) {
		int ans(0);
		for (int i = 2; i <= n / 2; i++) {
			if (p[i] && p[n - i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define N 1000000
using namespace std;
int pri[N];


int main(){
  for(int i=2;i*i<N;i++)
    if(pri[i]==0)for(int j=2;j<N/i;j++)pri[i*j]=1;
  while(1){
    int n;
    cin>>n;
    if(n==0) break;

    int cnt=0;
    for(int i=2;i<=n;i++){
      if(pri[i]==0) {
	int ans=n-i;
	if(pri[ans]==0 && i<=ans)cnt++;
      }
    }
    cout<<cnt<<endl;

  }

  return 0;
}

C++: /*1000000ÈºÌfÅüÍµ½nÈºÌÅåÌfðoÍ·évO*/
#include <iostream>
const int MAX = 1000001;
const int P_NUM = 78498;
using namespace std;

bool p[MAX];
int a[79000]={};

void f(){
    for(int i=0 ; i<MAX ; i++){
        p[i] = (i<=1)? false : true ;
    }
    for(int i=2 ; i*i<= MAX+1 ; i++){
        if( p[i] ){
            for(int j=i*2 ; j<MAX ; j+=i){
                p[j] = false;
            }
        }
    }
	for(int i=2,j=0; i<MAX ; ++i ){
		if(p[i])
			a[j++] = i;
	}
}

int main(){
    int n;

    f();

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

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