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++: //============================================================================
// Name        : TopCoderCompetition.cpp
// Author      : taguchi
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <bitset>
#include <algorithm>
#include <map>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <vector>
#include <numeric>
#include <list>
#include <sstream>
using namespace std;
//#define P pair<int,int>
//#define max 999999
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i,n) for(ull i = 0;i<n;i++)
#define pb(n) push_back(n)
#define clear(n) memset(n,0,sizeof(n))

typedef vector<int> vi;
typedef vector<string> vs;
struct edge{int cost,to;};

vector<string> split(string &in,char delimiter){
	vector<string> re; uint cur = 0,next;
	while((next = in.find_first_of(delimiter,cur)) != string::npos){
		re.pb(string(in,cur,next-cur));
		cur = next + 1;
	}
	re.pb(string(in,cur,in.size()-cur));
	return re;
}
vector<int> split_int(string &in, char delimiter){
	vector<string> str = split(in,delimiter);
	vector<int> re;
	rep(i,str.size()){
		re.pb(strtol(str[i].c_str(),NULL,10));
	}
	return re;
}

class Range{
public:
	int a,b;
	Range(int an,int bn) : a(an),b(bn){}

	bool operator()(int n){
		return a<=n&&n<=b;
	}
	bool isCross(Range x){
		return x(a) || x(b);
	}
	bool contains(Range x){
		return this->a <= x.a && x.b <= this->b;
	}
};

bool isprime[1000010];
uint primes[500010];
int main(){
	uint cnt = 0;
	for(int i = 2;i<1000010;i++){
		if(!isprime[i]){
			primes[cnt++] = i;
			for(int j = 2;i*j<1000010;j++){
				isprime[i*j] = true;
			}
		}
	}
	while(1){
		int n;
		cin >> n;
		if(!n)break;
		int result = 0;
		for(int k = 0;k<cnt;k++){
			if(binary_search(primes,primes+k+1,n-primes[k]))result++;
		}
		cout << result << endl;
	}

	return 0;
}

C++: #include <cstdio>
#include <cmath>
#define buf 1000000
using namespace std;
int k=0;
int B[buf];
void Search(int n);
int PrimeNumber(int n);
int main(void){
	int i,n;
	char str[buf];

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

void Search(int n){
	int i,j,cnt=0;
	for(i=0;i<k;i++){
			if(B[i]>n/2) break;
		for(j=i;j<k;j++){
			if(B[i]+B[j]==n)
				cnt+=1;
		}
	}
	printf("%d\n",cnt);
}
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;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[1000001];
    for(int i=2;i<=sqrt(1000000);i++){
        if(prime[i]==0){
            for(int j=i+i;j<1000001;j+=i)prime[j]=1;
        }
    }
    int n,cou=0;
    while(cin>>n&&n!=0){
        for(int i=2;i<=n/2;i++)if(prime[i]==0&&prime[n-i]==0)cou++;
        cout<<cou<<endl;
    cou=0;
    }
}

C++: #define _USE_MATH_DEFINES
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <stack>
#include <string>
#include <queue>
#include <cmath>
#include <math.h>
#include <numeric>
#include <list>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <climits>
#include <set>
#include <memory.h>
#include <memory>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cassert>
#include <map>
#include <cassert>
#include <time.h>
#include <ctime>

using namespace std;

typedef complex<double> xy_t;
typedef pair<xy_t, xy_t> line;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int , P> PP;
typedef pair<int, string> Ps;
typedef vector<int> vec;
typedef vector<vec> mat;
const int INF = 1 << 30;
const double EPS = 1e-9;
const double PI = 3.1415926535897932384626433832795;
const int CLK = CLOCKS_PER_SEC;

#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, m, n) for(int i = m; i < n; i++)

bool prime[1000000];
int main(){
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	for(int i = 2; i * i < 1000000; i++){
		if(prime[i]){
			for(int j = i * 2; j < 1000000; j += i){
				prime[j] = false;
			}
		}
	}
	int n;
	while(cin >> n && n){
		int cnt = 0;
		rep2(i, 2, n / 2 + 1){
			if(prime[i] && prime[n-i]) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

bool prime(int a) {
	if (a == 3)return true;
	for (int b = 3;; b+=2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	while (1) {
		int s = 0;
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 3; b < a / 2 + 1; b += 2) {
			if (prime(b) && prime(a - b))s++;
		}
		cout << s << endl;
	}
}

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

int main (){

	int arr[1000000];
	int N=1000000;

		for(int i = 0; i < N; i++){
			arr[i] = 1;
		}
		for(int i = 2; i < sqrt(N); i++){
			if(arr[i]){
				for(int j = 0; i * (j + 2) < N; j++){
					arr[i *(j + 2)] = 0;
				}
			}
		}
	
	while(1){
		int n,a=0;
		cin >> n;
		if(n==0)
			break;

		
		for(int i = 2; i <n; i++){
			if(arr[i]&&arr[n-i]&&i<=n-i)
				a++;
		}

		cout << a << endl;
	}
}

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

int p[1000000] = {};

int main()
{
	int n;

	for (int i = 2; i <= 1000000; ++i)
	{
		if (p[i-2] == 0)
		{
			p[i-2] = 1;
			for (int j = i+i; j <= 1000000; j += i) p[j-2] = -1;
		}
	}

	while (cin >> n && n)
	{
		int r = 0;
		for (int i = 2; i <= n/2; ++i) if (p[i-2] == 1 && p[n-i-2] == 1) ++r;
		cout << r << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstring>	// require memset 
//#include <fstream>

using namespace std;

const int N = 1000000;
bool prime[N+1];

void make_prime (void)
{
	int i,j;
	memset (prime, true , sizeof(prime) );

	prime[0] = false;
	prime[1] = false;

	for (j = 0; j <= N; ++j){
		if (prime[j]){
			int p = j;
			for (i = 2*p; i <= N; i += p ){
				if (prime[i] ){
					prime[i] = false;
				} // end if
			} // end for
		} // end if	
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.goldbachII", "r", stdin);

	string str = "";
	make_prime();

	while (getline (cin, str ) ){
		int n;
		stringstream ss(str);
		ss >> n;
		if (n == 0 ){
			break;
		} // end if
		int res = 0;
		int i;

		for (i = 2; i <= n/2; ++i){
			if (prime[i] && prime[n-i] ){
				++res;
			} // end for
		} // end for
		cout << res << endl;
	} // end loop
		
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define sup 1000000
using namespace std;

bool isinthevector(std::vector<int> v,int n)
{
	std::vector<int>::iterator i=find(v.begin(), v.end(),n);
	return i!=v.end();
}

int main(int argc, char const *argv[])
{
	std::vector<int> prm;
	prm.push_back(2);prm.push_back(3);
	bool isprm;
	for(int n=5;n<=sup;n+=2,isprm=true)
	{
		for (int i=0;prm[i]*prm[i]<=n;++i)
		{
			if(n%prm[i]==0)
			{
				isprm=false;
				break;
			}
		}
		if (isprm==true)
		{
			prm.push_back(n);
		}
	}

	int n;
	while(cin>>n,n)
	{
		int cnt=0;
		for (int i=0;2*prm[i]<=n;++i)
		{
			if (isinthevector(prm,n-prm[i]))
			{
				++cnt;
			}
		}
		cout<<cnt<<"\n";
	}
	return 0;
}