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 <cstdlib>
#include <vector>
using namespace std;

vector<int> sieve(int n) {
	vector<int> res(1, 2);
	vector<bool> prime(n, true);
	for(int i = 3; i < n; i += 2) {
		if(prime[i]) {
			res.push_back(i);
			for(int j = i * 3; j < n; j += i * 2)
				prime[j] = false;
		}
	}

	return res;
}

int main() {
	const int MAX = 1000000;
	vector<int> prime = sieve(MAX);

	for(int n; scanf("%d", &n), n;) {
		int ans = 0;
		for(int i = 0, j = prime.size() - 1; i < prime.size(); ++i) {
			while(j >= 0 && prime[i] + prime[j] > n) --j;

   			if(prime[i] + prime[j] == n) {
				ans += 1 + (i == j);
				--j;
			}
		}

   		printf("%d\n", ans / 2);
	}

	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(1000000, prime);

    vector<int> num;
    for(int i=0; i<=1000000; ++i){
        if(prime[i])
            num.push_back(i);
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        for(unsigned i=0; num[i]<=n/2; ++i){
            if(prime[n-num[i]])
                ++ ret;
        }
        cout << ret << endl;
    }
}

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=3;i<=n/2;i+=2){
			if(is_prime(i)&&is_prime(n-i))cnt++;
		}
		cout<<cnt<<endl;
	}
}

C++: #include<cstdio>
#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; i++){
			if(us[i] == true)continue;
			if(us[i] >= n)break;
			for(int j = i; j < n; j++){
				if(us[j] == true)continue;
				if(p[i] + p[j] > n)break;
				if(p[i] + p[j] == n){
					x++;
					us[i] = true;
					us[j] = true;
					break;
				}
			}
		}
		printf("%d\n",x);
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#define N 1000010
using namespace std;
int pri[N];


int main(){
  for(int i=2;i*i<=N;i++)
    if(pri[i]==0)for(int j=2;j<=N/i;j++)pri[i*j]=1;
  while(1){
    int n;
    cin>>n;
    if(n==0) break;

    int cnt=0;
    for(int i=2;i<=n;i++){
      if(pri[i]==0) {
	int ans=n-i;
	if(pri[ans]==0 && i<=ans)cnt++;
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
const int MAX_SIZE = 1000000;
bool p[MAX_SIZE+1];
int p_num[MAX_SIZE+1];
int p_count;

void prime_set(int MAX){
        p_count=0;
	p[0] = p[1] = false;
	for(int i=2; i<=MAX; i++) p[i] = true;
	int LIMIT = (int)sqrt(MAX);
	for(int i=2; i<=LIMIT; i++){
		if(p[i]){
			for(int j=2*i; j<=MAX; j++){
				if(j%i==0)
					p[j]=false;
			}
		}
	}
	
	for(int i=2; i<=MAX; i++){
		if(p[i]){
			p_num[p_count] = i;
			p_count++;
		}
	}
	
}

void slove(int n){
	int p,q,count=0;
	int k=0;
	while(p<(n/2)){
			p=p_num[k];
			for(int j=0; j<p_count; j++){
				q=p_num[j];
				if(p+q == n){
				 count++;
				}
			}
		k++;
	}
	cout << count << endl;
}

int main(){
	int n;
	while(cin >> n){
		if(n==0) break;
		prime_set(n);
		slove(n);
	}
	return 0;
}

C++: #include <cstdio>

#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 <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
bool prime[1000010];
void sieve(){
	for(int i =1;i <=1000000;i++){
		prime[i]=true;
	}
	prime[1]=false;
	for(int i =2;i*i<=1000000;i++){
		if(prime[i]){
			for(int j =i*i;j<=1000000;j+=i){
				prime[j]=false;
			}
		}
	}
}
int main(){
	int n;
	sieve();
	while(cin>>n,n){
		int ans = 0;
		for(int i =2;i <=n/2;i++){
			if(!prime[i])continue;
			for(int j =i;i+j<=n;j++){
				if(!prime[j])continue;
				if(i+j==n){
					ans++;
					//cout <<i<<" "<<j<<endl;
				}
			}
		}
		cout <<ans<<endl;
	}
	return 0;
}

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

int f[1000000],s[80000];

int main() {
   int n,i,j,k=0;
   for (i=2;i<1000000;i++) if (f[i]==0) {
	   f[i]=1; s[k++]=i;
	   for (j=i+i;j<1000000;j+=i) f[j]=2;
   }
   cout << "k=" << k << endl;
   while ( cin >> n && n>0) {
	   for (i=0,j=0;s[i]<=n/2;i++) if (f[n-s[i]]==1)  j++;
	   cout << j << endl;
   }  
return 0;
}

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

bool isPrime(int n){
	if(n <= 1){
		return false;
	}
	for(int i = 2; i*i <= n; i++){
		if(n%i == 0){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	while(cin >> n){
		if(n==0){
			break;
		}
		int cnt=0;
		for(int i=2;i<=n/2;i++){
			if(isPrime(i) && isPrime(n-i))
				cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

int n;
int p[100000];

int main()
{
	int t = 0;

	for (int i = 3; i < 1000000; i += 2) {
		bool f = 1;
		for (int j = 3; j * j <= i; j++) {
			if (i % j == 0) {
				f = 0;
				break;
			}
		}

		if (f) {
			p[t] = i;
			t++;
		}
	}

	cin >> n;

	while (n) {
		int m = 0, i = 0;

		while (p[i] * 2 <= n) {
			if (binary_search(p, p + t, n - p[i]))
				m++;

			i++;
		}

		cout << m << endl;

		cin >> n;
	}

	return 0;
}