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++: /* {{{ Shinobu kawaii */
/*
  ______   __        _                  __                 
.' ____ \ [  |      (_)                [  |                
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _   
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |  
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |, 
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/ 
                                                           
*/
/* }}} */

// #define int long long

/* cpp template {{{ */
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
using namespace std;

/* short */
#define pb push_back
#define mp make_pair
#define print(x) cout << x << '\n'
#define Fi first
#define Se second

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = 1; i <= (n); i++)
#define DEPS(i, a, n) for (int i = (a); i >= n; i--)
#define DEP(i, n) for (int i = (n); i >= 0; i--)

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = 999999999;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
inline bool inside(int y, int x, int H, int W) {return (y >= 0 && x >= 0 && y < H && x < W);}

/* }}} */

bool prime[1000001] = {1, 1};

signed main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  REPS(i, 2, 1000001){
    if (!prime[i]){
      for (int j = i + i; j < 1000001; j += i){
        prime[j] = true;
      }
    }
  }
  
  for (int n; cin >> n, n; ){
    int ans = 0;
    REP(i, n / 2 + 1){
      if (!prime[i] && !prime[n - i]){
        ans++;
      }
    }
    print(ans);
  }

  return (0);
}

C++: #include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

const int LIM=1000010;
bool sosu[LIM];

int main() {
	int i,j;
	for(i=0;i<LIM;i++){
		sosu[i]=true;
	}
	sosu[0]=sosu[1]=false;
	for(i=0;i<LIM;i++){
		if(sosu[i]){
			for(j=i*2;j<LIM;j+=i){
				sosu[j]=false;
			}
		}
	}
	int n;
	while(n=in()){
		int res=0;
		for(i=0;i<=n/2;i++){
			if(sosu[i]&&sosu[n-i])res++;
		}
		cout<<res<<endl;
	}
	return 0;
}

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

bool tab[1000100];
vector<int> primes;

void primetab() {
	for(int i = 0; i < 1000100; i++)
		tab[i] = true;
	tab[0] = tab[1] = false;
	for(int i = 0; i < 1000100; i++) {
		if(tab[i]) {
			primes.push_back(i);
			for(int j = 2; j * i < 1000100; j++) {
				tab[j*i] = false;
			}
		}
	}
}

int main() {
	int n;
	primetab();
	while(cin >> n, n) {
		int ans = 0;
		for(int i = 0; primes[i] <= n / 2; i++) {
			if(tab[n-primes[i]])
				ans++;
		}
		cout << ans << endl;
	}
}

C++: #include<iostream>
#define size 1000001
using namespace std;
int p[size];
int n,a,b,cnt;
void prime();
int main(){
  prime();
  while(1){
    cin>>n;
    if(n==0)break;
    cnt=0;
    for(int i=2;i<=n/2;i++){
      if(p[i]==1&&p[n-i]==1){
	//	cout<<i<<' '<<n-i<<endl;
	cnt++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

void prime(){
  for(int i=0;i<size;i++)p[i]=1;
  p[0]=p[1]=0;
  for(int i=4;i<size;i+=2)p[i]=0;
  for(int i=3;i*i<=size;i+=2){
    if(p[i]==0)continue;
    for(int j=i*2;j<size;j+=i)p[j]=0;
  }
}

C++: #include<stdio.h>
#include<string.h>

char so[1000001];

int main(){
	int n,i,j,count;
	memset(so,0,sizeof(so));
	so[1]=1;
	for(i=2;i<6;i++){
		for(j=2*i;j<=29;j+=i){
			so[j]=1;
		}
	}
	
	for(i=29;i<1000;i+=2){
		if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0)continue;
		for(j=3*i;j<=1000000;j+=(2*i)){
			so[j]=1;
		}
	}

	while(0<=scanf("%d",&n)){
		count=0;
		for(i=2;i<29;i++){
			if(2*i>n)break;
			if(n-i==3 || n-i==5 || n-i==7 || n-i==11 || n-i==13 || n-i==17 || n-i==19 || n-i==23 || n-i==29){
				if(so[i]==0){
					++count;
					continue;
				}
			}
			j=i;
			i=n-i;
			if(i%2==0 ||i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0){
				i=j;
				continue;
			}
			i=j;
			if(so[i]==0 && so[n-i]==0)++count;
		}
		
		for(i=29;2*i<=n;i+=2){
			if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0)continue;
			j=i;
			i=n-i;
			if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0){
				i=j;
				continue;
			}
			i=j;
			if(so[i]==0 && so[n-i]==0)++count;
		}
		printf("%d\n",count);

	}
	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]=false;
	table[1]=false;
	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 <cstdio>
#include <cmath>
#define buf 1000000
using namespace std;
int k=0;
int B[buf],A[buf*10]={0};
void Search(void);
int PrimeNumber(int n);
int main(void){
	int i,n;
	char str[buf];

	for(i=2;i<1000000;i++)
		PrimeNumber(i);
	Search();
	for( ;fgets(str,sizeof(str),stdin)!=NULL; ){
		sscanf(str,"%d",&n);
		if(n==0) break;
		printf("%d\n",A[n]);
	}
	return 0;
}

void Search(void){
	int i,j;
	for(i=0;i<k;i++){
			if(B[i]>buf/2) break;
		for(j=i;j<k;j++){
			A[B[i]+B[j]]+=1;
		}
	}
}
int PrimeNumber(int n){
	int i,c;
	if(n==2){
		B[k]=n;
		k++; return 0;
	}
	if(n<2 || n%2==0)
		return 0;
	c=sqrt(n);
	for(i=3;i<=c;i+=2){
		if(n%i==0)
			return 0;
	}
	B[k]=n;
	k++; return 0;
}