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 <cstdio>
#include <utility>
#include <cmath>
using namespace std;

#define _gp(l) const auto gcu{getchar##l}; const auto pcu{putchar##l}
#ifdef __linux
_gp(_unlocked);
#else
_gp();
#endif
#define _DEF(r, n, ...) inline r n(__VA_ARGS__) noexcept
#define _T template <typename T>
#define _HT template <typename H,typename... T>
#define _OP(t) inline operator t()
struct _in {
#ifdef _GLIBCXX_STRING
	_OP(string){string s;for(char c;c=gcu(),c!=' '&&c!='\n';)s+=c;return s;}
#define _S
#endif
	_OP(char){char c=gcu();gcu();return c;}
	_OP(double){double d; scanf("%lf",&d); gcu();return d;}
	_T _OP(T){T n{},m{1},c;if((c=gcu())=='-')m=-1,c=gcu();do{n=10*n+(c-'0'),c=gcu();}while(c>='0'&&c<='9');return m*n;}
} in;
#define _SCAN(...) _DEF(bool,scan,__VA_ARGS__)
#ifdef _S
_SCAN(string &o) {int c{gcu()};if(c==EOF)return false;else{ungetc(c,stdin);string t=move(in);o=t;return true;}}
#endif
_T _SCAN(T &o) {int c{gcu()};return c==EOF?false:(ungetc(c,stdin),o=in,true);}
_HT _SCAN(H &h,T&&... t){return scan(h)&&scan(t...);}
#define _OUT(...) _DEF(void,out,__VA_ARGS__)
#define _OUTL(...) _DEF(void,outl,__VA_ARGS__)
_OUT(bool b){pcu('0'+b);}
_OUT(const char *s){while(*s)pcu(*s++);}
_OUT(char c){pcu(c);}
#ifdef _S
_OUT(string &s){for(char c:s)pcu(c);}
#endif
_T _OUT(T n){static char b[20];char *p=b;T m=n<0?pcu('-'),-1:1;
	if(!n)*p++='0';else while(n)*p++=(char)(n%10*m+'0'),n/=10;while(p!=b)pcu(*--p);}
	_OUTL(){out('\n');}
#ifdef _GLIBCXX_VECTOR
	_T _OUT(vector<T> &v){for(T &x:v)out(&x == &v[0]?"":" "),out(x);}
#endif
	_HT _OUT(H &&h, T... t){out(h);out(t...);}
	template <typename... T> _OUTL(T... t){out(t...);outl();}
	struct range{
		int e,b=0,s=1;range(int _b,int _e,int _s):e(_e),b(_b),s(_s){} range(int _b,int _e): e(_e), b(_b){} range(int _e):e(_e){}
		struct it{int v,s; it(int _v,int _s):v(_v),s(_s){} operator int()const{return v;} operator int&(){return v;}int operator*()const{return v;}
			it& operator++(){v+=s;return *this;} }; it begin(){return {b,s};} it end(){return {e,s};}};
#define times(i,n) for(int i=n;i;i--)

template<int N>
struct sieve {
	bool s[N];
	int v[N], l = -1;
	sieve() : s(), v() {
		s[2] = true;
		for (int i = 3; i < N; i += 2)
			s[i] = true;
		for (int i = 9; i < N; i += 6)
			s[i] = false;
		for (int i = 6, e = sqrt(N); i <= e; i += 6) {
			for (int j : {i - 1, i + 1})
				if (s[j])
					for (int k = j * j; k < N; k += j)
						s[k] = false;
		}
		for (int i = 2; i < N; i++)
			if (s[i])
				v[++l] = i;;
	}
};

int main() {
	sieve<1000001> S;
	for (int n; (n = in);) {
		int c {};
		for (int i {}; S.v[i] <= n / 2; i++)
			if(S.s[n - S.v[i]])
				c++;
		outl(c);
	}
}

C++: #include <iostream>
#include <math.h>

using namespace std;

static const int N = 1000000;
bool P[N+1];

void prime()
{
	int limit;

	for(int i=2; i<=N; i++)
	{
		P[i] = true;
	}

	limit = sqrt((double)N);
	for(int i=2; i<limit; i++)
	{
		if(P[i])
		{
			for(int j=(i<<1); j<=N; j+=i)
			{
				if(P[j])
				{
					P[j] = false;
				}
			}
		}
	}
}

int main(int argc, char** argv)
{
	int n, c;
	prime();
	
	while(cin >> n, n)
	{
		c = 0;
		if(P[n-2]) c++;

		for(int i=3; i<=n/2; i+=2)
		{
			if(P[i] && P[n-i])
			{
				c++;
			}
		}

		cout << c << endl;
	}

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
bool is_prime(int n){
	for(int i=2;i*i<=n;i++){
		if(n%i==0)return false;
	}
	return n!=1;
}
int main(){
	int n;
	while(cin>>n,n){
		int cnt=0;
		for(int i=2;i<=n/2;i++){
			if(is_prime(i)&&is_prime(n-i))cnt++;
		}
		cout<<cnt<<endl;
	}
}

C++: #include<algorithm>
#include<iostream>
#include<vector>

bool isprime[1000001];
std::vector<int> primes;

void sieve()
{
	std::fill( isprime + 2, isprime + 1000001, true );

	for( int i = 2; i <= 1000000; ++i )
	{
		if( isprime[i] )
		{
			primes.push_back( i );

			for( int j = i * 2; j <= 1000000; j += i )
				isprime[j] = false;
		}
	}
}

int main()
{
	sieve();

	int n;
	while( std::cin >> n, n )
	{
		int ans = 0;

		for( int i = 0; i != primes.size() && primes[i] <= n / 2; ++i )
			if( isprime[n - primes[i]] )
				++ans;

		std::cout << ans << std::endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int memo[100000];
int dummy_prime(int n,int i){return memo[n] ? memo[n] : memo[n] = i>1 ? n%i ? dummy_prime(n,i-1) : -1 : 1;}
int isprime(int n){return memo[n] ? memo[n] : memo[n]=n>1 ? dummy_prime(n,sqrt(n)) : -1;}
int main()
{
	int n,result;
 
	while(cin >> n && n){
		result=0;
		for(int i=2;i<=n-i;i++)
			if(isprime(i)==1 && isprime(n-i)==1)result++;
		printf("%d\n",result);
	}
}

C++: #include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
bool us[1000010]={false};
int p[1000010] = {0};
int main(){
	/*Eratosthenes*/
	p[0] = 2;
	for(int i = 0; i <= 1000010; i+=2){
		us[i] = true;
	}
	
	int cnt = 1;
	for(int i = 3; i <= 1000010; i+=2){
		int q = 0;
		if(us[i] == true)continue;
		else if(us[i] == false){
			p[cnt] = i;
			cnt++;
			us[i] = true;
			q = i;
			for(int j = q+q; j <= 1000010; j += q){
				us[j] = true;
			}
		}
	}
	
	int n;
	while(scanf("%d",&n),n){
		int x = 0;
		memset(us,false,sizeof(us));
		for(int i = 0; i < n/2; i++){
			if(us[i] == true)continue;
			if(us[i] >= n)break;
			for(int j = i; j < n/2; j++){
				if(p[i] + p[j] > n)break;
				if(p[j] == true){
					if(p[i] +p[j] < n)continue;
					else break;
				}
				if(binary_search(p,p + (n/2),(n-p[i]))){
					x++;
					us[i] = true;
					us[j] = true;
					break;
				}
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
bool flag[10000001];

int main(){
    int n=0,ans=0;
	for(int i=0;i <= 1000000;i++){
		if(i<=1)flag[i]=false;
		else flag[i]=true;
	}
	for(int i=2;i <= 1001 ;i++){
		if(flag[i]==true){
			for(int j=i*2 ; j<=1000000 ; j=j+i){
				flag[j] = false;
			}
		}
	}
    while(cin>>n,n){
		ans=0;
		for(int i=2;i <= n/2;i++){
			if(flag[i]&&flag[n-i]){
				ans++;
			}
		}
		cout<<ans<<endl;
	}
}

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

bool p[1000000];

void erato(){
	fill(p, p+1000000, true);
	p[0] = p[1]= false;

	for(int i=0; i*i < 1000000; i++){
		if(!p[i])continue;
		for(int j= i+i; j < 1000000; j+= i){
			p[j] = false;
		}
	}
}

int main(){
	erato();
	int n;
	while(cin >> n, n){
		int ans = 0;
		for(int i=0; i <= n/2; i++){
			if(!p[i]) continue;
			if(p[n-i]) ans++;
		}
		cout << ans << endl;
	}
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<int> prime;
bool is_prime[1000010];
int min_factor[1000010];
int sieve(int n) {
  fill(is_prime + 2, is_prime + 1000010, true);
  min_factor[1] = 1;
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (int j = 2 * i; j <= n; j += i) {
        is_prime[j] = false;
        if (min_factor[j] == 0) min_factor[j] = i;
      }
    }
  }
  return prime.size();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  sieve(1000000);
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 1; prime[i] <= n - prime[i]; i++) {
      ans += is_prime[n - prime[i]];
    }
    cout << ans << endl;
  }

  return 0;
}