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>

#define MAX 100000
#define sqrtMAX 317

int main(void)
{
  int n;
  int *b;
  b = malloc((MAX+1)*sizeof(int));
  int *p;
  p = malloc((MAX+1)*sizeof(int));
  int *c;
  c = malloc((MAX+1)*sizeof(int));
/*
  int b[MAX+1] = {0};
  int p[MAX+1] = {0};
  int c[MAX+1] = {0};
*/
  int i, j;
  int count;

  // ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
  b[0] = 1;
  b[1] = 1;
  for(i=4; i<=MAX; i+=2)
      b[i] = 1;
  for(i=3; i<sqrtMAX; i+=2)
      for(j=i+i; j<=MAX; j+=i)
          b[j] = 1;

  // ツ素ツ青板づーツ板イツつォツ出ツつキ
  count = 0;
  for(i=0; i<=MAX; i++) {
    if(b[i])
      continue;
    p[count++] = i;
  }

  for(i=0; i<count; i++) {
    for(j=i; j<count; j++) {
      if(p[i]+p[j] > MAX)
        break;
      c[p[i]+p[j]]++;
    }
  }

  while(scanf("%d", &n)!=EOF) {
    if(n==0)
      break;
    printf("%d\n", c[n]);
  }

  free(b);
  free(p);
  free(c);

  return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int a[1000000]={1,1},s[0100000],c;
int main(){
	r(i,2,100000)
	for(int j=i*2;j<1000000;j+=i)a[j]++;
	r(i,2,1000000)if(!a[i])s[c++]=i;
int n;
while(cin>>n,n){
	int ss=0;
	r(i,0,n){
		if(s[i]>n)break;
	r(j,i,n){
		if(s[j]>n)break;
	if(s[i]+s[j]==n){ss++;}
	cout<<ss<<endl;
}
}
}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iterator>
#include <functional>
#include <utility>
#include <algorithm>
#include <numeric>
#include <typeinfo>

using namespace std;

#define dump(n) cout<<"# "<<#n<<"="<<(n)<<endl
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,n) repi(i,0,n)
#define iter(c) __typeof((c).begin())
#define foreach(i,c) for(iter(c) i=(c).begin();i!=(c).end();++i)
#define allof(c) (c).begin(),(c).end()
#define mp make_pair

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;

int main()
{
	vi isprime(1000001,true);
	isprime[0]=isprime[1]=false;
	repi(i,2,isprime.size())
		if(isprime[i])
			for(int j=i+i;j<isprime.size();j+=i)
				isprime[j]=false;
	vi primes;
	rep(i,isprime.size())
		if(isprime[i])
			primes.push_back(i);
	
	for(int n;cin>>n,n;){
		int res=0;
		rep(i,primes.size()){
			int p=primes[i];
			int q=n-p;
			if(p<=q && binary_search(allof(primes),q))
				res++;
		}
		cout<<res<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

VI eratosthenes()
{
	vector<bool> nums( 1000001, true );
	nums[0] = nums[1] = false;
	VI res;

	REP( i, 0, nums.size() )
	{
		if ( !nums[i] )
		{
			continue;
		}

		res.PB( i );
		for ( int j = 1; i * j < nums.size(); j++ )
		{
			nums[ i * j ] = false;
		}
	}

	return res;
}

int main()
{
	cin.tie( 0 );
	ios::sync_with_stdio( false );

	VI primes = eratosthenes();

	while ( true )
	{
		int n;
		cin >> n;

		if ( !n )
		{
			break;
		}

		int res = 0;
		REP( i, 0, primes.size() )
		{
			auto pos = lower_bound( ALL( primes ), n - primes[i] );
			if ( *pos != n - primes[i] || *pos < primes[i] )
			{
				continue;
			}
			res++;
		}

		cout << res << 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>
using namespace std;
bool isp[1<<20];
main()
{
    for(int i=2;i<1<<20;i++)isp[i]=1;
    for(int i=2;i<1<<20;i++)
    {
        if(!isp[i])continue;
        for(int j=i+i;j<1<<20;j+=i)isp[j]=0;
    }
    int n;
    while(cin>>n,n)
    {
        int cnt=0;
        for(int i=2;i+2<=n;i++)
        {
            cnt+=isp[i]&&isp[n-i];
        }
        cout<<cnt<<endl;
    }
}

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

using namespace std;

bool isPrime[1000000];
int primes[1000000];
int primeSize = 0;
int main()
{
	fill(isPrime, isPrime+1000000, true);
	for (int i = 2; i < 1000; ++i)
	{
		if (isPrime[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				isPrime[j] = false;
		}
	}
	for (int i = 3; i < 1000000; ++i)
		if (isPrime[i])
			primes[primeSize++] = i;

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 0; primes[i] <= n/2; ++i)
			if (isPrime[n - primes[i]])
				++ans;
		printf("%d\n", ans);
	}

	return 0;
}

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

vector<int> sieve(int n) {
  vector<int> prime(n);
  for(int i=2; i<n; i++) prime[i]=i;
  for(int i=2; i*i<n; i++) {
    if(prime[i]) {
      for(int j=i*i; j<n; j+=i) prime[j]=0;
    }
  }
  prime.erase(remove(prime.begin(), prime.end(), 0), prime.end());
  return prime;
}

int main() {
  vector<int> prime=sieve(1000000);
  while(1) {
    int n, cnt=0;
    cin >> n;
    if(n==0) break;
    int check=0;
    for(vector<int>::iterator it=prime.begin(); *it<=n/2; it++) {
      int x=*it, t;
      t=distance(prime.begin(), lower_bound(prime.begin(),prime.end(), n-x));
      if(x+prime[t]==n) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int prime[300],count=0;
	for(int i=3;i<1000;i+=2){
		bool t=true;
		for(int j=0;j<count;j++)
			if(i%prime[j]==0)t=false;
		if(t==true){
			prime[count]=i;
			count++;
		}
	}
	int n;
	while(true){
	cin>>n;
	if(n==0)
		break;
	int ans=0;
	for(int i=3;i<=n/2;i+=2){
		bool t=true;
		for(int j=0;j<count;j++){
			if(i%prime[j]==0&&i!=prime[j])t=false;
			if((n-i)%prime[j]==0&&(n-i)!=prime[j])t=false;
		}
		if(t==true)ans++;
	}
	cout<<ans<<endl;
	}
	return 0;
}