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 <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 10e15+9
#define MOD 1000000007
#define EPS 1e-10
#define MAX_N 100100
#define MAX_M 100100

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;
typedef pair<P, char> PC;

int n;

bool is_prime[1001000];

int main(){
	fill(is_prime, is_prime + 1001000, 1);
	is_prime[0] = 0;
	is_prime[1] = 0;
	for (int i = 2; i <= 1000000; i++){
		if (is_prime[i]){
			for (int j = i * 2; j <= 1000000; j += i){
				is_prime[j] = 0;
			}
		}
	}

	while (cin >> n&&n){
		int ans = 0;
		FOR(i, 1, n / 2 + 1){
			if (is_prime[i] && is_prime[n - i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

#define MAX 1000001
//#define MAX 100

set<int> primes;
bool is_prime[MAX];

/*
void print_set(set<int> s)
{
	set<int>::iterator it = s.begin();
	printf("set (");
	while (it != s.end())
	{
		printf(" %d", *it);
		++it;
	}
	printf(" )\n");
}
*/

int n;

signed main()
{
	rep(i,MAX) is_prime[i] = true;
	is_prime[1] = false;
	for (int i=2; i<MAX; i++)
	{
		if (is_prime[i])
		{
			primes.insert(i);
			for (int j=i*2; j<MAX; j+=i)
			{
				is_prime[j] = false;
			}
		}
	}

	while (true)
	{
		cin >> n;
		if (n == 0) break;
		int ans = 0;
		for (int i=2; i<=n/2; i++)
		{
			if (primes.find(i) != primes.end() && primes.find(n - i) != primes.end())
			{
				ans++;
			}
		}
		printf("%d\n", ans);
	}

	//print_set(primes);
	//printf("END\n");
}

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

int main()
{
	int  a,d,n;
	bool prime[SIZE];

	for(int i=0; i<SIZE; i++)
	{
		prime[i]=1;
	}
	prime[0]=prime[1]=0;

	for(int i=2; i<SIZE; i++)
	{
		if(prime[i])
		{
			for(int j=2; j*i<SIZE; j++)
			{
				prime[j*i]=0;
			}
		}
	}
	
	int N;
	while(cin >> N, N)
	{
		int cnt=0;
		for(int i=0; i<=N/2; i++)
		{
			if(prime[i]&&prime[N-i])
			{
				cnt++;
			}
		}
		
		cout << cnt << endl;
	}
}

C++: #include <stdio.h>

#define MAX_NUM (1000000)

char prime[MAX_NUM + 1];

void make_prime()
{
	for (int i = 0; i < MAX_NUM + 1; i++){
		prime[i] = 1;
	}
	prime[0] = prime[1] = 0;
	
	for (int i = 2; i * i < MAX_NUM; i++){
		if (prime[i] == 1){
			for (int j = 2; j * i <= MAX_NUM; j++){
				prime[j * i] = 0;
			}
		}
	}
}

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

C++: #include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
    bool latte[1000000];
    fill(latte,latte+1000000,true);
    latte[0]=latte[1]=false;
    for(int i=2;i<1000000;i++){
        if(latte[i]){
            for(int j=i+i;j<1000000;j+=i)latte[j]=false;
        }
    }

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

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

int prime[MAX-4];

void is_prime(){
    for(int i = 0 ; i < MAX ; i++) prime[i] = 0;
    prime[0] = prime[1] = 1;
    for(int i = 4 ; i < MAX ; i += 2) prime[i] = 1;
    
    for(int i = 3 ; i*i < MAX ; i++){
        if(prime[i]) continue;
        for(int j = i*2 ; j < MAX ; j+= i)
            prime[j] = 1;
    }
}

    int main(){
        int n;
        
        is_prime();
        
        while(true){
            cin >> n;
            if(!n) break;
            
            int cnt = 0;
            for(int i = 2 ; i <= n/2 ; i++){
                if(!prime[i]&&!prime[n-i]) cnt++;
            }
            cout << cnt << endl;
        }
        
        return 0;
    }

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second

template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pll> pip;
const ll INF = 1ll<<60;
const ll MOD = 1000000007;
const double EPS  = 1e-9;

vector<int> sieve(int n) {
	vector<int> res;
	vector<bool> is_prime(n + 1, true);
	
	is_prime[0] = is_prime[1] = false;
	
	for (int i = 2; i * i <= n; i++) if (is_prime[i]) {
		res.push_back(i);
		is_prime[i] = false;
		for (int j = 2; i * j <= n; j++) if (is_prime[i * j]) {
			is_prime[i * j] = false;
		}
	}
	
	REP(i, n + 1) if (is_prime[i]) res.push_back(i);
	sort(res.begin(), res.end());
	return res;
}

int main() {
	vector<int> prime = sieve(1000000);
	set<int> ss;
	REP(i, prime.size()) ss.insert(prime[i]);
	
	int n;
	while (cin >> n, n) {
		int ans = 0;
		REP(i, prime.size()) {
			if (prime[i] * 2 > n) break;
			if (ss.find(n - prime[i]) != ss.end()) ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

int p[1000000];
int pt[1000000];
int pn;

int dp[1000001];

void init(){
  memset(p,1,sizeof(int)*1000000);
  memset(pt,0,sizeof(int)*1000000);
  memset(dp,0,sizeof(int)*1000001);
  p[0] = p[1]  = 0;
  for(int i =0; i < 1000; i++){
    if(p[i]){
      for(int j = i +i;j < 1000000;j +=i){
	p[j] = 0;
      }
    }
  }
  pn =0;
  for(int i = 0; i < 1000000;i++){
    if(p[i]){
      pt[pn] = i;
      pn++;
    }
  }
}

int solve(int t){
  int res = 0;  
  for(int i =0 ;pt[i]<=t/2;i++){
    if(p[t-pt[i]]){
      res++;
    }
  }
  return res;
}


int main(){
  int in;
  init();
  while(1){
    cin>>in;
    if(!in){
      break;
    }
    cout << solve(in) << endl;
  }
}

C++: #include <iostream>
#include <stdlib.h>
using namespace std;
#define limit 1000010

int main(void){
  int* table=(int*)malloc(sizeof(int)*limit);
  for(int i=0;i<limit;i++){
    table[i]=1;
  }
  table[0]=0;
  table[1]=0;
  int k;
  for(int i=0;i<limit;i++){
    if(table[i]==0)continue;
      k=2;
      while(k*i<=limit){
        table[k*i]=0;
        k++;
      }
  }
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    int retval=0;
    for(int i=1;i<=n/2;i++){
      if(table[i]==1 && table[n-i]==1){
        retval++;
      }
    }
    cout<<retval<<endl;
  }

  return 0;
}