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<iostream>
#include<vector>

using namespace std;

int main()
{
	int n;
	vector<int> prime;
	int i,j;
	
	for(i=0;i<1000000;i++)
	{
		prime.push_back(1);
	}
	prime[0]=prime[1]=0;
	
	for(i=0;i<1000000;i++)
	{
		if(prime[i]==1)
		{
			for(j=2;j*i<1000000;j++)
			{
				prime[i*j]=0;
			}
		}
	}
	
	for(;;)
	{
		cin >> n ;
		if(n==0)
			break;
		
		int ans=0;
		
		for(i=0;i<=n-i;i++)
		{
			if(prime[i]==1)
			{
				if(prime[n-i]==1)
				{
					ans++;
//					cout << "f1:" << i << " f2:" << n-i << " ans:" << ans << endl;
				}
			}
		}
		
		cout << ans << endl;
		
	}
}

C++: #include<iostream>
using namespace std;
bool a[1000001];
int main() {
	fill(a, a + 1000001, true);
	a[0] = false;
	a[1] = false;
	for (int i = 2; i <= 1000000;) {
		if (a[i]) {
			int j = 2;
			while (i*j <= 1000000) {
				a[i*j] = false;
				j++;
			}
		}
		if (i % 2 == 0)i++;
		else i += 2;
	}
	int n;
	while (cin >> n&&n != 0) {
		int sum = 0;
		if (a[n - 2]) sum++;
		for (int i = 3; i <= n / 2 ; i+=2) {
			if (a[i] && a[n - i]) sum++;
		}
		cout << sum << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <cstring>

//isprimeðìÁÄ­êéÖ
int* prime(int num){
	std::vector<int> v;
	int* res = new int[num+1];
	memset(res, 0, sizeof(res));
	res[2] = 1;
	v.push_back(2);

	bool f;
	for(int i=3;i<=num;i+=2){
		f = true;
		for(int j=0;v[j]*v[j]<=i;j++){
			if(i % v[j] == 0){f=false;break;}
		}
		if(f){v.push_back(i),res[i] = 1;}
	}

	return res;
}

int main(){
	int* isprime = prime(1000000);

	int n, res = 0;
	while(std::cin >> n, n){
		res = 0;
		for(int i=2;i<=n/2;i++){
			if(isprime[i] && isprime[n-i])res++;
		}
		std::cout << res << std::endl;
	}
	
	return 0;
}

C++: j,p[1<<20],n;
main(i)
{
	for(;++i<999;)
		if(!p[i])
			for(j=i+i;j<1<<20;j+=i)
				p[j]=1;
	for(;scanf("%d",&n),j=0,n;printf("%d\n",j))
		for(i=2;i<=n/2;i++)if(!p[i]&!p[n-i])j++;
	exit(0);



}

C++: #include<iostream>
#include<cstdio>
#include<cstring>

using namespace std;

bool prime[1000002];

void seive(int s){
	for(int i=0;i<=s;i++)prime[i]=true;
	prime[0]=prime[1]=false;
	for(int i=2;i<=s;i++){
		if(prime[i]==true){
			for(int j=i*2;j<=s;j+=i)prime[j]=false;
		}
	}
}

int main(void){
	seive(1000000);
	while(1){
		int n;
		int ans=0;
		scanf("%d",&n);
		if(n==0)break;
		for(int j=3;j<=n/2;j+=2){
			if(prime[j]==true && prime[n-j]==true)ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int PrimeMax = 1000000;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[PrimeMax];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  vary(int,v,0,0);
  v.clear();
  rep(i,PrimeMax){
    if(is_prime[i] != 0){
      v.pb(i);
    }
  }
  int n;
  while(cin >> n&&n){
    int res = 0;
    REP(i,2,v.size()){
      if(v[i] + *lower_bound(all(v),n - v[i]) == n){
        res++;
      }
    }
    cout << res/2 << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
using namespace std;
#define MAX 1000001

bool isPrime[MAX];

void eratos() {
    fill(isPrime, isPrime + MAX, true);
    for (int i = 2; i < MAX; i++) {
        if (!isPrime[i]) continue;
        for (int j = i + i; j < MAX; j += i) {
            isPrime[j] = false;
        }
    }
}

int main() {
    eratos();
    int n;
    while (true) {
        cin >> n;
        if (n == 0) return 0;
        int count = 0;
        for (int i = 2; i <= n / 2; i++) {
            if (!isPrime[i]) continue;
            if (isPrime[n - i]) count++;
        }
        cout << count << endl;
    }
}

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 && n-era[i]<1000000 && data[n-era[i]]==false && era[i]<=n-era[i]){
                sum++;
            }
        }
        cout<<sum<<endl;
    }
    
    return 0;
}

C++: 134
4330
34808
98792
0