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++: 
// @snippet<sh19910711/contest:headers.cpp>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <numeric>
#include <limits>
#include <complex>
#include <functional>
#include <iterator>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>

// @snippet<sh19910711/contest:solution/define_classes.cpp>
namespace solution {
  class Solution;
  class Solver;
  class Storages;
}

// @snippet<sh19910711/contest:solution/interface.cpp>
namespace solution {
  class SolutionInterface {
  public:
    virtual ~SolutionInterface() {};
    virtual int run() = 0;
    
  protected:
    SolutionInterface() {}
    virtual void pre_calc() {}
    virtual bool action() = 0;
    virtual void init() {};
    virtual bool input( Storages& s ) { return false; };
    virtual void output( const Storages& s ) const {};
    virtual void before_action( const int& test_no ) const {}
    virtual void after_action( const int& test_no ) const {}
  };
}

// @snippet<sh19910711/contest:solution/solution-base.cpp>
namespace solution {
  class SolutionBase: public SolutionInterface {
  public:
    virtual ~SolutionBase() {}
    virtual int run() {
      this->pre_calc();
      for (;;) {
        this->before_action(-1);
        if ( ! this->action() ) { this->after_action(-1); break; }
        this->after_action(-1);
      };
      return 0;
    }
  protected:
    SolutionBase() {}
  };
}

namespace math {
  template <int SIZE> class PrimeChecker {
  public:
    void init() {
      std::fill( P + 0, P + SIZE, false );
      for ( int i = 3; i < SIZE; i += 2 )
        P[i] = true;
      P[2] = true;
      for ( int i = 3; i < SIZE; i += 2 ) {
        if ( P[i] )
          for ( int j = i + i; j < SIZE; j += i )
            P[j] = false;
      }
    }
    bool P[SIZE];
  };
}

// @snippet<sh19910711/contest:solution/typedef.cpp>
namespace solution {
  typedef std::istringstream ISS;
  typedef std::ostringstream OSS;
  typedef long long Int;
  typedef long double Double;
  typedef std::string String;
  
}

// @snippet<sh19910711/contest:solution/namespace-area.cpp>
namespace solution {
  // namespaces, types
  using namespace std;
  const int SIZE = 1000000 + 11;
  typedef math::PrimeChecker<SIZE> PrimeChecker;
}

// @snippet<sh19910711/contest:solution/consts-area.cpp>
namespace solution {
  // constant vars
  
  
}

// @snippet<sh19910711/contest:solution/storages-area.cpp>
namespace solution {
  // storages
  class Storages {
  public:
    Int N;
    PrimeChecker P;
    Int result;
  };
  
  Storages global_storages;
}

// @snippet<sh19910711/contest:solution/solver-area.cpp>
namespace solution {
  class Solver {
  public:
    void solve( Storages& s ) {
      s.result = count_numbers(s.N, s.P);
    }
    
    static Int count_numbers( const Int& N, const PrimeChecker& P ) {
      Int res = 0;
      for ( int i = 0; i * 2 <= N; ++ i ) {
        if ( P.P[i] && P.P[N - i] )
          res ++;
      }
      return res;
    }
    
  protected:
    
  };
}

// @snippet<sh19910711/contest:solution/solution.cpp>
namespace solution {
  class Solution: public SolutionBase {
  public:
    Solution() {}
    Solution(Storages* p): storages(p) {
      p->P.init();
    }
    
  protected:
    virtual bool action() {
      this->init();
      if ( ! this->input(*this->storages) )
        return false;
      solver.solve(*this->storages);
      this->output(*this->storages);
      return true;
    }
    
    bool input( Storages& s ) {
      return std::cin >> s.N && s.N;
    }
    
    void output( const Storages& s ) const {
      std::cout << s.result << std::endl;
    }
    
  private:
    Solver solver;
    Storages* storages;
  };
}

// @snippet<sh19910711/contest:main.cpp>
#ifndef __MY_UNIT_TEST__
int main() {
  std::cin.sync_with_stdio(false);
  return solution::Solution(&solution::global_storages).run();
}
#endif

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
using namespace std;

#define rep(i,n) for((i)=0; (i)<(int)(n); ++(i))
#define foreach(c,i) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)

const int MAX_N = 1000002;
int n;
vector<int> prime(1,2);
bool sieve[MAX_N];

int solve() {
  const int half = *lower_bound(prime.begin(), prime.end(), n/2);
  int ans = 0;
  for (int i = 0; i < prime.size(); ++i) {
    if (half < prime[i]) break;
    const int value = n - prime[i];
    if (binary_search(prime.begin(), prime.end(), value)) ans++;
  }
  return ans;
}

int main() {
  fill(sieve, sieve + MAX_N, true);
  sieve[0] = sieve[1] = false;
  for (int i = 4; i < MAX_N; i+=2) sieve[i] = false;
  for (int i = 3; i < MAX_N; i+=2) if (sieve[i]) {
    prime.push_back(i);
    for (int j = i + i; j < MAX_N; j+=i) sieve[j] = false;
  }
  while (cin >> n, n) {
    cout << solve() << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int prime[200];
int main(){
	int 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;
		n/=2;
		int ans=0,k=n*2-3;
		bool t;
		for(int i=3;i<=n;i+=2){
			t=true;
			for(int j=0;j<count;j++){
				if(i%prime[j]==0){
					if(i!=prime[j]){
						t=false;
						break;
					}
				}
				if(k%prime[j]==0){
					if(k!=prime[j]){
						t=false;
						break;
					}
				}
			}
			if(t)ans++;
			k-=2;
		}
		cout<<ans<<endl;
	}
	getchar();
	getchar();
	return 0;
}

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

vector<int> prime;
bool isPrime[1000001];
void primeCalc()
{
	for(int i = 0; i < 1000001; ++i)
	{
		isPrime[i] = true;
	}
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < 1000001; ++i)
	{
		if(isPrime[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < 1000001; j += i)
			{
				isPrime[j] = false;
			}
		}
	}
}

void solve()
{
	primeCalc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		int pos = 0;
		while(prime[pos] <= n / 2)
		{
			if(isPrime[n - prime[pos]])
			{
				++count;
			}
			++pos;
		}
		cout << count << endl;
	}
}

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

C++: // 2011/06/22 Tazoe

#include <iostream>
using namespace std;

void sieve(bool is_prime[], int n)
{
	for(int i=0; i<n; i++)
		is_prime[i] = true;

	if(n>=1)
		is_prime[0] = false;
	if(n>=2)
		is_prime[1] = false;

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

int main()
{
	bool is_prime[1000001];
	sieve(is_prime, 1000001);

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

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

		cout << cnt << endl;
	}

	return 0;
}