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 <cmath>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int prime[1000001];

void CreatePrime(int n)
{
	rep(i,n)
	{
		prime[i] = 1;
	}

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

	REP(i,2,sqrt(n))
	{
		if(prime[i])
		{
			for(int j=0;i*(j+2) < n;j++)
			{
				prime[i*(j+2)] = 0;
			}
		}
	}
}

int main()
{
	CreatePrime(1000001);
	
	int n;
	while(cin >> n && n)
	{
		int count = 0;
		REP(i,2,(n/2)+1)
		{
			if(prime[i] == 1 && prime[n-i]) count++;
		}

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

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

int main(){
	bool prime[1000001] = {true,true};
	vector<int> ps;
	for(int i = 4;i <= 1000000;i += 2) prime[i] = true;
	for(int i = 3;i * i <= 1000000;i += 2){
		for(int j = i * 2;j <= 1000000;j += i) prime[j] = true;
	}
	for(int i = 0;i <= 1000000;i++) if(!prime[i]) ps.push_back(i);
	int n;
	while(cin >> n,n){
		int cnt = 0;
		for(int i = 0;i < ps.size();i++){
			if(ps[i] > n / 2) break;
			if(upper_bound(ps.begin(),ps.end(),n - ps[i]) - lower_bound(ps.begin(),ps.end(),n - ps[i])) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

#define MAX 1000000
typedef long long ll;

void ESieve(ll n, vector<bool> &ispr) {
  ispr.assign(n+1, true);
  ispr[0] = ispr[1] = false;
  
  for(int i=0; (ll)i*i<=n; i++) {
    if(ispr[i]) {
      for(int j=2*i; j<=n; j+=i) {
	ispr[j] = false;
      }
    }
  }
}

int main() {
  vector<bool> isPrime;
  ESieve(MAX, isPrime);

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

C++: //00
#include<iostream>

using namespace std;

int main(){
  static bool cmp[500001]={true,true};
  for(int i=2;i<500001;i++){
    if(!cmp[i]){
      for(int j=2;i*j<500001;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n;cin>>n,n;){
    int ans=0;
    for(int i=0;i+i<=n;i++){
      ans+=!cmp[i]&&!cmp[n-i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(){
	bool prime[1000001] = {true,true};
	vector<int> ps;
	for(int i = 4;i <= 1000000;i += 2) prime[i] = true;
	for(int i = 3;i * i <= 1000000;i += 2){
		for(int j = i * 2;j <= 1000000;j += i) prime[j] = true;
	}
	for(int i = 0;i <= 1000000;i++) if(!prime[i]) ps.push_back(i);
	int n;
	while(cin >> n,n){
		int cnt = 0;
		for(int i = 0;i < ps.size();i++){
			if(ps[i] > n / 2) break;
			if(find(ps.begin(),ps.end(),n - ps[i]) != ps.end()) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

using namespace std;

bool prime[1000000];

int main() {

  int n;

  int ans;


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

  for(int i=2;i<=1000000;i++) prime[i]=true;
  
  for(int i=2;i<=sqrt(1000000);i++) {

    if(prime[i]==true) {

      for(int j=2*i;j<=1000000;j+=i) {

	prime[j]=false;

      }

    }

  }
  
  while(1) {

    cin >> n;

    if(n==0) break;

    ans=0;

    for(int i=2;i<=n/2;i++) {

      if(prime[i]==true && prime[n-i]==true) ans++;

    }

    cout << ans << endl;

  }
  
  return 0;

}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=999991;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j] <= i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(i);
    }
    cout << primes.back() << endl;
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int ans = 0;
	for(int i=0;primes[i]<=n/2;i++){
	    int j = lower_bound(ALL(primes),n-primes[i]) - primes.begin();
	    if(primes[j] + primes[i] == n) {
		ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}

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

int isprime[1000001] = { 0 };

int main() {

  isprime[1]=1;
  for(int i=4; i<1000001; i+=2)
    isprime[i] = 1;

  for(int i=3; i<1000001; i++) {
    if(isprime[i] == 0)
      for(int j=2; i*j<1000001; j++)
	isprime[i*j] = 1;
  }

  int n;

  while(true) {
    cin>>n;
    if(!n) break;

    int res=0;
    for(int i=2; i<n/2+1; i++)
      if( (isprime[i] == 0) && (isprime[n-i] == 0) ) {
	//cout<<i<<"+"<<n-i<<"="<<n<<endl;
	res++;
      }

    cout<<res<<endl;
  }
}

C++: #include <algorithm>
#include <cctype>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

vector<bool> eratos(int n)
{
	vector<bool> isprime(n+1, true);
	isprime[0] = isprime[1] = false;
	for(int i=2; i*i<=n; ++i){
		if(isprime[i]){
			for(int j=i*2; j<=n; j+=i)
				isprime[j] = false;
		}
	}
	return isprime;
}

int main()
{
	vector<bool> isprime = eratos(1000000);
	
	int n;
	while(scanf("%d", &n), n){
		int cnt = 0;
		rep(i, n/2+1)
			cnt += isprime[i] && isprime[n-i];
		printf("%d\n", cnt);
	}
	return 0;
}

C++: #include<vector>
#include<iostream>
#include<algorithm>
using namespace std;
namespace AOJ0185
{
	class Primes
	{
	public:
		static void GetPrimes(int max, vector<int> &primes)
		{
			vector<bool> flags(max + 1, true);
			for (int i = 2; i <= max; i++)
			{
				if (flags[i])
				{
					primes.push_back(i);
					for (int j = i; j <= max; j += i)
					{
						flags[j] = false;
					}
				}
			}
		}
	};

	class Solver
	{
	private:
		static const int MAX_N = 1000001;
		int Input()
		{
			int n;
			cin >> n;
			return n;
		}

		void Output(int answer)
		{
			cout << answer << endl;
		}

	public:
		void Solve()
		{
			vector<int> primes;
			Primes::GetPrimes(MAX_N, primes);

			int n;
			while (n = Input())
			{
				int answer = 0;
				for (int i = 0; i < primes.size(); i++)
				{
					int diff = n - primes[i];
					if (diff < primes[i])break;
					bool exist = binary_search(primes.begin(), primes.end(), diff);
					if (exist)answer++;
				}
				Output(answer);
			}
		}

	};
}

int main()
{
	AOJ0185::Solver().Solve();
}