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>
#include <cmath>
#include <algorithm>

#define NUM 1100000

int main(){
	int limit;
	int* table = new int[NUM];

	for(int i=0; i < NUM;i++)table[i] = 1;
	table[0] = 0;
	table[1] = 0;

	limit = sqrt(NUM);

	for(int i=2;i<=limit;i++){
		if(table[i] == 1){
			for(int k=2*i;k < NUM; k += i){
				table[k] = 0;
			}
		}
	}

	int n,count;

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

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

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

const int NMAX=1000000;

int main() {
  bool p[NMAX+1];
  vector<int> pv;
  for (int i=2; i<=NMAX; i++) {
    p[i] = true;
  }
  for (int i=2; i*i<=NMAX; i++) {
    if (!p[i]) continue;
    for (int j=i+i; j<=NMAX; j+=i) {
      p[j] = false;
    }
  }
  for (int i=2; i<=NMAX; i++) {
    if (p[i]) pv.push_back(i);
  }

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

  return 0;
}

C++: #include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<vector>
#include<queue>
using namespace std;
int sosu[1000001];
vector<int> s;
int N;
int main(){
  for(int i=2;i<1000000;i++){
    if(sosu[i]) continue;
    s.push_back(i);
    for(int j=i+i;j<1000000;j+=i){
      sosu[j]=1;
    }
  }
  while(scanf("%d",&N),N){
    int res = 0;
    for(int i=0;i<=(int)s.size();i++){
      int h = N - s[i];
      //    printf("%d %d\n",s[i],h);
      if(h<0) break;
      if(h<s[i]) break;
      if(!sosu[h]) res ++;
    }
    printf("%d\n",res);
  }
}

C++: #include <bits/stdc++.h>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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

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

int main() {
  int n;
  prime();

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

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

int p[5000000];

bool prime(int x){
  if(x==2) return false;
  
  if(x<1||x%2==0) return false;

  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return false;
    i+=2;
  }
  return true;
}

int main(){
  int n,ans;
 

  int j=0;
  for(int i=3;i<=1000000;i++) if(prime(i)) p[j++]=i;
  while(1){
    ans=0;
    cin>>n;
    if(n==0) break;
    for(int i=0;p[i]<n;i++){
      for(int j=i;p[j]<n;j++){
	if(n==(p[i]+p[j])){
	 
	  ans++;
	  break;
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
char t[1001];
int size,n,tmp,cnt,a,b,c,x,y,z,flg;
int endofinput(){
  if(t[12]!='\n')return 0;
  if(t[0]!='E')return 0;
  if(t[1]!='N')return 0;
  if(t[2]!='D')return 0;
  if(t[3]!=' ')return 0;
  if(t[4]!='O')return 0;
  if(t[5]!='F')return 0;
  if(t[6]!=' ')return 0;  if(t[9]!='P')return 0;
  if(t[7]!='I')return 0;  if(t[10]!='U')return 0;
  if(t[8]!='N')return 0;  if(t[11]!='T')return 0;
  return 1;
}
int main(){
  while(1){
    size=0;
    while(1){
      scanf("%c",&t[size]);
      size++;
      if(t[size-1]=='\n')break;
    }
    if(endofinput())break;
    cnt=0;
    flg=0;
    if(t[0]!=' ')cnt=1;
    for(int i=1;i<size-1;i++){
      if(t[i]==' '){
	cout<<cnt;
	cnt=0;
	flg=1;
      }else{
	cnt++;
	flg=0;
      }
    }
    cout<<cnt<<endl;
  }

  return 0;
}

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

const int MAX = 1000000;
int primes[80000];
int pNum;

void calcPrimes() {
    primes[0] = 2;
    pNum = 1;
    for (int i = 3; i <= MAX; i += 2) {
        bool add = true;
        for (int j = 0; j < pNum; j++) {
            if (primes[j] * primes[j] > i) {
                break;
            }
            if (i % primes[j] == 0) {
                add = false;
                break;
            }
        }
        if (add) {
            primes[pNum++] = i;
        }
    }
}

int main() {
    calcPrimes();
    while (true) {
        int n;
        cin >> n;
        if (n == 0) {
            break;
        }
        int pi = 0, qi = pNum - 1, ans = 0;
        while (pi <= qi) {
            int sum = primes[pi] + primes[qi];
            if (sum <= n) {
                if (sum == n) {
                    ans++;
                }
                pi++;
            } else {
                qi--;
            }
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
#include<iomanip>
#include<algorithm>
#define shosu(x) fixed<<setprecision(x)
using namespace std;

int n;

bool sosu(int x){
	for(int i=2;i*i<=x;i++){
		if(x%i==0) return false;
	}
	return x!=1;
}

int main(){
	while(1){
		int ans=0;
		cin>>n;
		if(!n) break;
		for(int i=2;i<=n;i++){
			if(sosu(n-i)&&sosu(i)){
				ans++;
			}
		}
		cout<<(ans-1)/2+1<<endl;
	}
}

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>
#include<vector>
#define MAX 500000
using namespace std;
int main(){
	vector<int> a(MAX);
	vector<int> box(MAX);
	int n,sum,k=0,l,r,mid;
	for(int i=0;i<MAX;i++)
	a[i]=1;
	a[0]=0;a[1]=0;
	for(int i=0;i*i<MAX;i++)
	if(a[i]){
		for(int j=i*2;j<MAX;j+=i)
		a[j]=0;
	}
	for(int i=0;i<MAX;i++)
	if(a[i])
	box[k++]=i;
	while(cin>>n,n){
		sum=0;
		for(int i=0;box[i]<n;i++){
			if(box[i]*2<n)
			continue;
				l=0;r=i;
				while(r-l>1){
					mid=(r+l)/2;
					if(box[mid]>=n-box[i]){
						r=mid;
					}else {
						l=mid;
					}
				}
			if(box[r]+box[i]==n){
				sum++;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}