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>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include <numeric>
#include<map>
 
 
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 1e13
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
 
typedef long long int ll;
#define MOD 1000000007


/*nまでの素数を列挙して配列に保持*/
vector<int> Eratosthenes(int n,vector<int>& arr){

	for(int i = 0; i < n;i++){
		arr[i] = 1;
    }
    arr[0] = arr[1] = 0;

	for(int i = 2; i < sqrt(n); i++){
		if(arr[i]){
			for(ll j = 0; i * (j + 2) < n; j++){
				arr[i *(j + 2)] = 0;
			}
		}
    }
    return arr;
}


int main(){


    int n;
    int tmp = 1000000;
    vector<int> arr(tmp);


    arr = Eratosthenes(tmp,arr);/*50000までの素数を列挙*/
    
    while(cin >> n,n){
        int count = 0;
        for(int i = 2;i <= n/2;i++){

            if(i <= n-i && arr[i] && arr[n-i]){
                count++;
            }
        }
        cout << count << endl;
    }
    
    
    return 0;
}

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

#define N 1000000

int main(void){
	vector<bool> isprime(N+1);
	for(int i=0;i<isprime.size();i++) isprime[i]=true;
	int upto = (int)sqrt(isprime.size());
	isprime[1]=false;
	for(int i=2;i<=upto;++i){
		if(isprime[i]){//消されてなければその倍数を消す
			for(int j=2;i*j<isprime.size();++j) isprime[i*j] = false;
		}
	}
	int n;
	while(cin>>n,n){
		int c=0;
		for(int i=2;i<=n/2;++i){
			if(isprime[i]&&isprime[n-i])++c;
		}
		cout<<c<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
#define NN 1000001;

int main(){

bool f[(1000001)];
int c=0,x;

for(int i=3;i<1000001;i+=2)
f[i]=true;

for(int i=3;i<1000001;i+=2)
for(int j=3;j<=sqrt((double)(i));j+=2)
{if(i%j==0){f[i]=false;break;}

}
while(1){
scanf("%d",&x);if(x==0)break;
for(int i=3;i<x;i+=2)
for(int j=x-1;j>=i;j-=2)
	if((f[i]==true&&f[j]==true)&&i+j==x){printf("%d+%d\n",i,j);c++;}

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

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

#define MN 1000001
bool pr[MN] = {0};

int main()
{
	for(int i=2; i<MN; i++) { pr[i] = 1; }
	for(int i=2; i*i<MN; i++)
	{
		if(pr[i])
		for(int j=i*2; j<MN; j+=i)
		{
			pr[j] = 0;
		}
	}

	int n,c;
	while(cin >> n, n)
	{
		c = 0;
		for(int i=3; i<n/2+1; i++)
		{
			if(pr[i] && pr[n-i]) c++;
		}
		cout << c << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

vector<int> get_prime(int n){
    if(n <= 1) return vector<int>();
    vector<bool> is_prime(n+1, true);
    vector<int> prime;
    is_prime[0] = is_prime[1] = 0;
    for (int i = 2; i <= n; ++i) {
        if(is_prime[i]) prime.emplace_back(i);
        for (auto &&j : prime){
            if(i*j > n) break;
            is_prime[i*j] = false;
            if(i % j == 0) break;
        }
    }
    return prime;
}

auto p = get_prime(1000000);

int main() {
    int n;
    while(cin >> n, n){
        int l = 0, ans = 0;
        for (int i = p.size()-1; i >= 0; --i) {
            while(l < i && p[l]+p[i] < n) l++;
            ans += (p[i]+p[l] == n);
        }
        cout << ans << "\n";
    }

    return 0;
}

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

using namespace std;
bool IsPrime[1000001];

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for(int i = 2; i < 1000001; ++i)
	{
		if(IsPrime[i])
		{
			for(int j = 2 * i; j < 1000001; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		int temp = n / 2;
		for(int i = 0; i <= temp; ++i)
		{
			if(IsPrime[i] == 1 && IsPrime[n - i] == 1)
			{
				count++;
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n) n.begin(),n.end()

const int MAX = 1000001;
bool p[MAX];
int ps[MAX];
//vector<int> ps(MAX);
int l;
int s[MAX];
int n;

int main()
{
    p[0] = p[1] = 1;
    REP(MAX)if(!p[i])for(int j=i*2;j<MAX;j+=i) p[j] = true;
    REP(MAX)if(!p[i]){ ps[l] = i; l++;}
    
    //cout << "made ps "  << l << endl;

    REP(l)
        for(int j = i;j<l;j++)
        {
            if(ps[i]+ps[j] < MAX) s[ps[i] + ps[j] ] ++;
            else break;
        }

    cout << "made sum "<< endl;
    while(cin >> n && n) cout << s[n] << endl;

    return 0;
}

C++: #include <iostream>

using namespace std;

const int Max = 1000000;
bool P[Max];

void eratos()
{
	for( int i = 0;i < Max;i++ ) P[i] = true;

	P[0] = P[1] = false;

	for( int i = 0;i < Max;i++ ) if( P[i] == true ) for( int j = 2;i * j < Max;j++ ) P[i * j] = false;
}


int main(int argc, char const* argv[])
{
	int n;

	eratos();

	while( cin >> n && n != 0 ){
		int count = 0;

		for( int i = 2;i <= n/2;i++ ) if( P[i] ) if( P[n - i] ) count++;

		cout << count << endl;
	}
	return 0;
}

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

using namespace std;

int main()
{
	static bool era[1000001]={true,true};
	for(int i=2;i<1000;i++){
		if(!era[i])
			for(int j=i*i;j<1000000;j+=i)	era[j]=true;
	}

	vector<int> p;
	for(int i=2;i<1000000;i++)	if(!era[i])	p.push_back(i);

	for(int n;cin>>n,n;){
		int cnt=0;
		for(int i=0;p[i]<=n/2;i++)	if(!era[n-p[i]])	cnt++;
		cout<<cnt<<endl;
	}

	return 0;
}

C++: // 2011/08/02 Tazoe

#include <iostream>
using namespace std;

void eratos(bool prm[], int n)
{
	if(n>=1)
		prm[0] = false;
	if(n>=2)
		prm[1] = false;

	for(int i=2; i<n; i++)
		prm[i] = true;

	for(int i=2; i<n; i++)
		if(prm[i])
			for(int j=i+i; j<n; j+=i)
				prm[j] = false;
}

int main()
{
	bool prm[1000001];		// for AOJ
	eratos(prm, 1000001);

	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		int cnt = 0;
		for(int p=2; p<=n-p; p++)
			if(prm[p]&&prm[n-p])
				cnt++;

		cout << cnt << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
bool so[1000000];

int main(){
  so[0]=so[1]=1;
  for(int i=2;i*i<=1e6;i++)
    if(!so[i]) for(int j=2;j<=1e6/i;j++)so[i*j]=1;
  
  int n;
  while(cin>>n,n){
    
    int ans=0;
    for(int i=2;i<=n-1&&i<=n-i;i++)
      if(!so[i]&&!so[n-i])ans++;
    
    cout<<ans<<endl;

  }
  return 0;
}