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 <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;

bool a[2000000];

int main(){
	
	int N = 1500000;
	
	for(int i = 0; i < N; i++){
		a[i] = true;
	}
	
	a[0] = false;
	a[1] = false;
	
	for(int i = 2; i < N; i++){
		if(a[i]){
			for(int j = i * 2; j < N; j += i){
				a[j] = false;
			}
		}
	}
	
	int n, ans;
	
	while(true){
		cin >> n;
		if(n == 0){
			break;
		}
		ans = 0;
		for(int i = 0; i < n; i++){
			if(i > n - i){
				break;
			}
			if(a[i] && a[n - i]){
				ans++;
			}
		}
		printf("%d\n", ans);
	}
	
	return 0;
}

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

int p[78500],flg[1000004],size;

bool isPrime(int x){
	for(int i=0;i<size && p[i]<=sqrt(x);i++){
		if(x % p[i] == 0) return false;
	}
	return true;
}

void mkPrime(void){
	p[0] = 2;
	flg[2] = size = 1;

	for(int i=3;i<=1000000;i+=2){
		if(isPrime(i)){
			p[size++] = i;
			flg[i] = 1;
		}
	}
}

int main(void){
	int x;

	mkPrime();

	while(cin>>x && x){
		int ans = 0, to = x / 2;
		for(int i=0;p[i]<=to;i++){
			if(flg[x-p[i]]) ans++;
		}
		cout<<ans<<endl;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <queue>
 
using namespace std;
 
#define pb(n)	push_back(n)
#define mp(n,m) make_pair(n,m)
#define fi 	first
#define se 	second
#define all(r) (r).begin(),(r).end()

#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,a,b) for(int i=(a); i<(b); i++)

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
const int IMAX=((1<<30)-1)*2+1;
const double EPS=1e-10;
//int mod=1000000007


vi v(1000100,1);


int main(){
	v[0]=0;
	v[1]=0;
	for(int i=2; i<1000100; i++){
		if(v[i]==1){
			for(int j=2; j<1000100/i; j++){
				v[i*j]=0;
			}
		}
	}
	int n,ans;
	while(cin>>n && n>0){
		ans=0;
		for(int i=2; i<=n/2; i++){
			if(v[i]==1 && v[n-i]==1)ans++;
		}
		cout<<ans<<endl;
	}
}

C++: #include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
bool us[1000010]={false};
bool p[1000010] = {0};
int main(){
	/*Eratosthenes*/
	p[2] = true;
	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[i] = true;
			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;
		for(int i = 0; i <= n/2; i++){
			if(p[i] && p[n-i]){
				x++;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

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

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

using namespace std;

#define MAX 1000000
 
bool prime[MAX];
 
void make()
{
    fill(prime, prime + MAX, true);
 
    prime[0] = prime[1] = false;
    for (int i = 2; i*i < MAX; i++) { 
	if (prime[i]) {
	    for (int j = 2*i; j < MAX; j += i) {
		prime[j] = false;
	    }
	}
    }
}
 
int main()
{
    make();
    int n;
    while (scanf("%d", &n), n) {
	int cnt = 0;
	for (int i = 2; i+i <= n; i++) {
	    if (prime[i] && prime[n-i]) {
		cnt++;
	    }
	} 
	printf("%d\n", cnt);
    }
    return 0;
}

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

int p[5000000];

bool prime(int x){
  if(x==2) return false;
  
  if(x<1||x%2==0) return false;

  int i=3;
  while(i<=sqrt(x)){
    if(x%i==0)return false;
    i+=2;
  }
  return true;
}

int main(){
  int n,ans;
 

  int j=0;
  for(int i=3;i<=1000000;i++) if(prime(i)) p[j++]=i;
  while(1){
    ans=0;
    cin>>n;
    if(n==0) break;
    for(int i=0;p[i]<=(n+1)/2;i++){
      if(prime(n-p[i])) ans++;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main() {
	bool NonPrime[1000000+1]={0};
	NonPrime[0]=NonPrime[1]=true;
	for(long i=2;i<=1000000;i++){
		if(NonPrime[i]) continue;
		for(long j=2*i;j<=1000000;j+=i) NonPrime[j]=true;
	}
	vector<long> Prime;
	vector<long>::iterator vp;
	for(long i=2;i<=1000000;i++) if(!NonPrime[i]) Prime.push_back(i);
	while(1){
		long n; cin >> n ; if(!n) break;
		long cnt=0;
		for(vp=Prime.begin();vp<Prime.end();vp++){
			if(n-*vp<2 || n-*vp<*vp) break;
			if(!NonPrime[n-*vp]) cnt++;
		}
		cout << cnt << '\n' ;
	}
}