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 <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

bool isPrime(int n){
    if(n==2)return true;
    for(int i=2;i<=sqrt(n);i++){
        if(n%i==0)return false;
    }
    return true;
}

bool data[1000000]={true,true};

vi makeEra(){

    for(int i=2;i<1000000;i++){
        if(data[i]==false){
            if( isPrime(i) ){
                for(int j=2;;j++){
                    if(i*j<=1000000)
                        data[i*j]=true;
                    else break;
                }
            }
        }
    }
    vi ret;
    rep(i,1000000){
        if(data[i]==false){
            ret.pb(i);
        }
    }
    return ret;
}


int main() {
    vi era=makeEra();
    
    int len=era.size();
    
    int n;
    while(cin>>n){
        if(n==0)break;
        int sum=0;
        rep(i,len){
            if(n-era[i]>=0 && data[n-era[i]]==false && era[i]<=n-era[i]){
                sum++;
            }
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

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

bool is_prime[1000001];

void sieve() {
  for(int i=0;i<1000001;i++) {
    is_prime[i] = true;
  }
  is_prime[0] = is_prime[1] = false;

  for(int i=2;i*i<1000001;i++) {
    if(is_prime[i]) {
      for(int j=2*i;j<1000001;j+=i) {
        is_prime[j] = false;
      }
    }
  }
}

int main() {
  int n,ans=0;
  sieve();
  while(cin >> n) {
    if(n==0) break;

    for(int i=2;i<=(n+1)/2;i++) {
      if(is_prime[i]) {
        if(is_prime[n-i]) {
          ans++;
        }
        else continue;
      }
      else continue;
    }
    cout << ans << endl;
    ans = 0;
  }
}

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

int x[10000000];

void prime(int p) {
	x[2] = 1;
	for (int i = 3; i < p; i += 2) {
		for (int j = 3; j*j <= i; j += 2) {
			if (i%j == 0) { goto E; }
		}
		x[i] = 1;
	E:;
	}
}

int gold(int p) {
	int sum = 0;
	for (int i = 2; i <= p / 2; i++) {
		if (x[i] + x[p - i] == 2) { sum++; }
	}
	return sum;
}

int n;

int main() {
	prime(3000000);
	while (true) {
		cin >> n;
		if (n == 0) { break; }
		cout << gold(n) << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll prime(ll x) {
	ll i;
	if (x < 2)return 0;
	else if (x == 2) return 1;
	if (x % 2 == 0) return 0;
	for (i = 3; i*i <= x; i += 2) {
		if (x%i == 0) return 0;
	}
	return 1;
}
int main() {
	int x;
	while (cin >> x, x) {
		ll cnt = 0; 
		for (int i = 2; i <= x; i++) {
			if (2 * i <= x && prime(i) && prime(x - i)) cnt++;
		}
		cout << cnt << endl;
	}
}

C++: 
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 500000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}



int main(){
	erats();
	int n;
	while(cin>>n&&n!=0){
		int cnt=0;
		for(int i = 0; i < p; i++){
			if(prime[i]>(n/2))
				break;
			for(int j = i; j < p; j++){
				if(prime[i]+prime[j]==n){
//					cout<<prime[i]<<" "<<prime[j]<<endl;
					cnt++;
				}
				if(prime[i]+prime[j]>=n)
					break;
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

template<int m>
class Prime{
  std::vector<bool> p;
  std::vector<int> ps;
public:
  Prime(){
    p = std::vector<bool>(m,true);
    assert(m>1);
    p[0]=p[1]=false;
    for(int i=4;i<m;i+=2)
      p[i]=false;
    ps.push_back(2);
    for(int i=3;i<m;i+=2){
      if(p[i]){
        ps.push_back(i);
        for(int j=i+i;j<m;j+=i)
          p[j]=false;
      }
    }
  }

  bool isPrime(int n){
    assert(m>n);
    return p[n];
  }

  int operator [] (int n){
    if(n<ps.size()) return ps[n];
    else return 0;
  }

  int size(){
    return ps.size();
  }
};

int main(){
  Prime<10000000+100> p;
  int n;
  while(cin>>n, n){
    int ans = 0;
    for(int i=0; p[i] + p[i] <= n; i++){
      if(p.isPrime(n - p[i]))
        ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

bool ifnotprime[1000000];

void setPrimes(){
    ifnotprime[0] = ifnotprime[1] = true;
    for(int n = 2; n*n < 1000000; n++){
        if( !ifnotprime[n] ){
            int m = n*n;
            while(m < 1000000){
                ifnotprime[m] = true;
                m += n;
            }
        }
    }
}

int main(){
    setPrimes();
    int n, i;
    while(cin >> n, n){
        int ans = 0;
        for(i = 2; i <= n/2; i++){
            if( !ifnotprime[i] && !ifnotprime[n-i] ){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}