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++: j,p[1<<20],n;main(i){for(;++i<999;)for(j=i;!p[i]&(j+=i)<1<<20;)p[j]=1;for(;scanf("%d",&n),j=0,n;printf("%d\n",j))for(i=1;++i<=n/2;)j+=!p[i]&!p[n-i];exit(0);}

C++: #include<bits/stdc++.h>
using namespace std;
#define MAX 1000005
bool isPrime(int n){
  for(int i=2;i*i<=n;i++) if(n%i==0) return 0;
  return 1;
}
int main(){
  int n;
  bool d[MAX]={};
  for(int i=2;i<MAX;i++) d[i]=isPrime(i);
  while(cin>>n,n){
    int ans=0;
    for(int i=2;i<=n/2;i++){
      if(d[i]&&d[n-i]) ans++;
    }cout << ans << endl;
  }
}

C++: #include<iostream>
using namespace std;
bool prime[1000000];
int main(){
	for(int i = 2; i * i <= 1000000; i++){
		if(prime[i] == 0){
			for(int j = i; j <= 1000000; j+=i){
				prime[j] = 1;
			}
			prime[i] = 0;
		}
	}
	int n;
	while(cin >> n,n){
		int cnt = 0;
		for(int i = 2; i <= n/2; i++){
			if(prime[i])continue;
			else {
				if(!prime[n-i])cnt++;
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <iostream>
#define MAX 1000000

using namespace std;

int isprime[MAX];
int prime[80000] = {0};

void ERATOSUTENESUNOHURUI(void){

  for( int i = 0 ; i < MAX ; i++ ) isprime[i] = 1;
  isprime[0] = isprime[1] = 0;

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

}


int main(void){

  ERATOSUTENESUNOHURUI();

  int I = 0;
  for( int i = 2 ; i < MAX ; i++ ){
    if( isprime[i] ){
      prime[I++] = i;
    }
  } 
  I++;

  int n;
  while( cin >> n , n ){
 
    int cnt = 0;
    for( int i = 0 ; i < n ; i++ ){
      for( int j = i ; j < n ; j++ ){
	if( i < I && j < I ){
	  if( n == prime[i] + prime[j] ) cnt++;
	}
      }
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int dummy_prime(int n,int i){return i>1 ? n%i ? dummy_prime(n,i-1) : 0 : 1;}
int isprime(int n){return n>1 ? dummy_prime(n,sqrt(n)) : 0;}
int main()
{
int n,result;
while(cin >> n && n){
result=0;
for(int i=2;i<=n-i;i++)result+=(isprime(i)+isprime(n-i))/2;
cout<<result<<endl;
}
}

C++: /*1000000ÈºÌfÅüÍµ½nÈºÌÅåÌfðoÍ·évO*/
#include <iostream>
const int MAX = 1000001;
const int P_NUM = 78498;
using namespace std;

bool p[MAX];
int a[79000]={};

void f(){
    for(int i=0 ; i<MAX ; i++){
        p[i] = (i<=1)? false : true ;
    }
    for(int i=2 ; i*i<= MAX+1 ; i++){
        if( p[i] ){
            for(int j=i*2 ; j<MAX ; j+=i){
                p[j] = false;
            }
        }
    }
	for(int i=2,j=0; i<MAX ; ++i ){
		if(p[i])
			a[j++] = i;
	}
}

int main(){
    int n;

    f();

    while( cin >> n , n ){
		int ans = 0;
		int pos;
		for(pos = 0 ; n > a[pos] ; ++pos );

		for(int i=0 ; i<=pos ; ++i ){
			for(int j=pos ; j>=i ; --j ){
				if( a[i]+a[j] == n ){
					ans++;
					continue;
				}
				if( a[i]+a[j] < n ){
					continue;
				}
			}
		}
		cout << ans << endl;
    }
}

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;
		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;
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
int main(){
	bool prime[1000001];
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i<=1000000;i++){
		if(prime[i]){
			for(int j=2*i;j<=1000000;j+=i)prime[j]=false;
		}
	}
	int n;
	while(cin>>n,n){
		int cnt=0;
		for(int i=3;i<=n/2;i+=2){
			if(prime[i]&&prime[n-i])cnt++;
		}
		cout<<cnt<<endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

int N = 1000001;
int prime_array[1000001];

void Eratosthenes(){
  for(int i = 0; i < N; i++){
    prime_array[i] = 1;
  }
  for(int i = 2; i < sqrt(N); i++){
    if(prime_array[i]){
      for(int j = 0; i * (j + 2) < N; j++){
	prime_array[i *(j + 2)] = 0;
      }
    }
  }
  
  for(int i = 2; i < N; i++){
    if(prime_array[i]){
      //cout << i << endl;
    }
  }
}

int main()
{
  Eratosthenes();
  int n;

  while( cin >> n, n ) {
    int cnt = 0;
    for(int i=2; i<=n/2; i++) {
      if( prime_array[i] && prime_array[n-i] ) cnt++;
    }

    cout << cnt << endl;
  }

}

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

const int NMAX=1000000;

int main() {
  bool p[NMAX+1];
  vector<int> pv;
  for (int i=2; i<NMAX; i++) {
    p[i] = true;
  }
  for (int i=2; i*i<=NMAX; i++) {
    if (!p[i]) continue;
    for (int j=i+i; j<=NMAX; j+=i) {
      p[j] = false;
    }
  }
  for (int i=2; i<=NMAX; i++) {
    if (p[i]) pv.push_back(i);
  }

  int n, ans;
  while (1) {
    cin >> n;
    if (!n) break;
    ans = 0;
    for (int i=0; i<pv.size(); i++) {
      if (pv[i] >= n - pv[i]) break;
      if (p[n-pv[i]]) ++ans;
    }
    cout << ans << endl;
  }

  return 0;
}

C++: #include <bits/stdc++.h>
using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int PrimeMax = 1000000;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[PrimeMax];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  vary(int,v,0,0);
  v.clear();
  rep(i,PrimeMax){
    if(is_prime[i] != 0){
      v.pb(i);
    }
  }
  int n;
  while(cin >> n&&n){
    int res = 0;
    REP(i,0,v.size()){
      if(v[i] + *lower_bound(all(v),n - v[i]) == n){
        res++;
      }
      if(v[i] > n) break;
    }
    cout << (1+res)/2 << endl;
  }
  return 0;
}