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>
using namespace std;

int prime[1000001];
bool is_prime[1000001];

int res(int n)
{
	int p=0;
	for(int i=0;i<n+1;i++){
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for(int i=2;i<n+1;i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j=2*i;j<n+1;j+=i){
				is_prime[j] = false;
			}
		}
	}
	return p;
}
int binsearch(int key,int left,int right)
{
	while(left<=right){
		int middle = (left+right)/2;
		if(key == prime[middle])
			return 1;
		else if(key<prime[middle])
			right = middle-1;
		else
			left = middle+1;
	}
	return 0;
}
int main()
{
	int n;
	int count;
	int p = res(1000000);
	while(cin >> n){
		if(n==0)
			break;
		count = 0;
		for(int i=0;i<p;i++){
			if(prime[i] < n/2+1)
				count+=binsearch(n-prime[i],i,p);
			else
				break;
		}
		cout << count << endl;
	}
	return 0;
}

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

bool prime(int a) {
	if (a == 3)return true;
	for (int b = 3;; b+=2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	while (1) {
		int s = 0;
		int a;
		cin >> a;
		if (a == 0)break;
		for (int b = 3; b < a / 2 + 1; b += 2) {
			if (prime(b) && prime(a - b))s++;
		}
		cout << s << endl;
	}
}

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

vector<bool> IsPrime;
vector<int> primes;

void sieve(int max) {
    IsPrime.resize(max + 1, true);
    IsPrime[0] = IsPrime[1] = false;
    for (int i = 2; i * i <= max; ++i){
        if (IsPrime[i]){
            for (int j = i * i; j <= max; j += i) IsPrime[j] = false;
        }
    }
    for(int i = 0; i <= max; ++i) if(IsPrime[i])primes.push_back(i);
}

int main() {
    sieve(int(1e6));
    int n;
    while(cin >> n, n){
        int ans = 0;
        for(int i=0;primes[i]*2<=n;i++){
            if(IsPrime[n-primes[i]]) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,a,b;
	bool primes[1000001];
        primes[2] = true;
        for (int i = 3; i < 1000001; i += 2) {
                primes[i] = true;
        }
        for (int i = 3; i * i < 1000001; i += 2) {
                if (primes[i]) {
                for (int j = i * 2; j < 1000001; j += i) {
                 primes[j] = false;
                 }
            }
        }
	while(true){
		int cnt=0;
		cin >> n;
		b=n/2;
		if(n==0) break;
		for(int i=0;i<b+1;i++){
			if(primes[i]==true){
				a=n-i;
				if(primes[a]==true){
					cnt++;
				}
			}
		}
		cout << cnt << endl;
	}
	return 0;
}

C++: //00
#include<iostream>

using namespace std;

int main(){
  static bool cmp[1000001]={true,true};
  for(int i=2;i<1000001;i++){
    if(!cmp[i]){
      for(int j=2;i*j<1000001;j++){
	cmp[i*j]=true;
      }
    }
  }
  for(int n;cin>>n,n;){
    int ans=0;
    for(int i=0;i+i<=n;i++){
      ans+=!cmp[i]&&!cmp[n-i];
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

const int MAX = 1000000;
int notp[MAX + 1];

void prime(){
	notp[0] = 1;
	notp[1] = 1;
	
	for(int i = 2; i <= MAX; ++i){
		int j = i * 2;
		while(j <= MAX){
			notp[j] = 1;
			j += i;
		}
	}
}

int main(){
	int n, c;
	prime();
	
	while(c = 0, cin >> n, n){
		for(int i = 3; i <= n / 2; ++i){
			if(notp[i] == 0 && notp[n - i] == 0) ++c;
		}
		cout << c << endl;
	}
	
	return 0;
}

C++: #include <cstdio>
#define MAX 1000001

int a[ MAX ] = {0};

int main( void ){
	int n;
	int counter;
	
	
	for( int i = 2; i <= MAX; i++ ){
		if( a[ i ] ){ continue; }
		for( int j = i * 2; j <= MAX; j += i ){
			a[ j ] = 1;
		}
	}
	
	while(1){
		scanf( "%d", &n ); 
		if(!n){break;}
		counter = 0;
		for( int i = 2; i <= n / 2; i++ ){
			int comp = n - i;
			if( !a[ i ] && !a[ comp ] ){
				counter++;
			}
		}
		printf( "%d\n", counter );
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
#include<cmath>
bool isprime(int n) {
	if (n == 2)return true;
	if (n % 2 == 0)return false;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	int n; while (cin >> n, n) {
		int cnt = 0;
		for (int i = 2; i <= n / 2; i++) {
			if (isprime(i) && isprime(n - i)){cnt++;
		}
		cout << cnt << endl;
	}
}

C++: #include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
//#define int long long
using namespace std;

#define MAX 1000001
//#define MAX 100

set<int> primes;
bool is_prime[MAX];

void print_set(set<int> s)
{
	set<int>::iterator it = s.begin();
	printf("set (");
	while (it != s.end())
	{
		printf(" %d", *it);
		++it;
	}
	printf(" )\n");
}

signed main()
{
	rep(i,MAX) is_prime[i] = true;
	is_prime[1] = false;
	for (int i=2; i<MAX; i++)
	{
		if (is_prime[i])
		{
			primes.insert(i);
			for (int j=i*2; j<MAX; j+=i)
			{
				is_prime[j] = false;
			}
		}
	}

	print_set(primes);
}

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

#define MAX 1000000
#define sqrtMAX sqrt(MAX)

int main(void)
{
  int n;
  vector<int> b(MAX+1);
  vector<int> p(MAX+1);
  vector<int> c(MAX+1);
  int i, j;
  int count;

  // ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
  b[0] = 1;
  b[1] = 1;
  for(i=4; i<=MAX; i+=2)
      b[i] = 1;
  for(i=3; i<sqrtMAX; i+=2)
      for(j=i+i; j<=MAX; j+=i)
          b[j] = 1;

  // ツ素ツ青板づーツ板イツつォツ出ツつキ
  count = 0;
  for(i=0; i<=MAX; i++) {
    if(b[i])
      continue;
    p[count++] = i;
  }

  for(i=0; i<count; i++) {
    for(j=i; j<count; j++) {
      if(p[i]+p[j] > MAX)
        break;
      c[p[i]+p[j]]++;
    }
  }

  while(scanf("%d", &n)!=EOF) {
    if(n==0)
      break;
    printf("%d\n", c[n]);
  }
  return 0;
}

C++: #include <vector>
#include <map>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

const int INF = 10000000;
using namespace std;
typedef long long  ll;
const int MAX = 1000010;

/** Problem0185 : Goldbach's Conjecture II **/
int main()
{
	bool prime[MAX];
	int  input, count;
	
	for (int i=0; i<MAX; i++)
		prime[i] = true;
	
	prime[0] = false; prime[1] = false;
	
	for (int i=2; i<MAX; i++) {
		if (prime[i]) {
			for (int j=2; i*j<MAX; j++) {
				prime[i*j] = false;
			}
		}
	}
	
	while (1) {
		cin >> input;
		if (input == 0) break;
		
		count = 0;
		for (int i=2; i<=input/2; i++) {
			if (prime[i] && prime[input - i])
				count++;
		}
		
		cout << count << endl;
	}
	return 0;
}

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

#define MAX_N 1000001

bool table[MAX_N];

void init() {
    memset(table, 1, sizeof(table));
    table[0] = table[1] = false;
    for (int i = 2; i < MAX_N; i++) {
        if (table[i]) {
            for (int j = i + i; j < MAX_N; j += i) {
                table[j] = false;
            }
        }
    }
}

int main() {
    init();
    int n;
    while (cin >> n) {
        if (n == 0) break;
        int count = 0;
        for (int i = 2; i <= n/2; i++) {
            if (table[i] && table[n - i]) {
//                cout << i << ' ' << n - i << endl;
                count++;
            }
        }
        cout << count << endl;
    }
    return 0;
}