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

const int MX = 1000001;
bool sieve[MX];

int main() {
    memset(sieve, 0, sizeof sieve);
    sieve[0] = sieve[1] = true;
    for (int i=2; i*i<MX; ++i) {
        if (sieve[i]) continue;
        for (int j=i*i; j<MX; j+=i) {
            sieve[j] = true;
        }
    }
    int n;
    while (cin >> n, n) {
        int cnt = 0;
        for (int i=0; 2*i<=n; ++i) {
            if ( ! sieve[i] && ! sieve[n-i]) {
                ++ cnt;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

C++: #include<iostream>
#define N 1000001
using namespace std;
int main(){
  int n;
  int p[N]={0};
  for(int i=3;i<=N;i+=2;) p[i] = 1;
  p[2] = 1;
  for(int i=3;i<=1000;i+=2){
    if(p[i]==1){
      for(int j=2*i;j<=N;j+=i) p[j] = 0;
    }
  }
  while(cin>>n){
    int count = 0;
    if(n==0) break;
    int j = n - 2;
    if(p[j]==1) count++; 
    for(int i=3;i<=n/2;i+=2){
      if(p[i]==1) j = n - i;
      if(p[j]==1) count++;
    }
    cout << count << endl;
  }
  return 0;
}

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

int main()
{
	int  a,d,n;
	bool prime[SIZE];

	for(int i=0; i<SIZE; i++)
	{
		prime[i]=1;
	}
	prime[0]=prime[1]=0;

	for(int i=2; i<SIZE; i++)
	{
		if(prime[i])
		{
			for(int j=2; j*i<SIZE; j++)
			{
				prime[j*i]=0;
			}
		}
	}
	
	int N;
	while(cin >> N, N)
	{
		int cnt=0;
		for(int i=0; i<=N/2; i++)
		{
			if(prime[i]&&prime[N-i])
			{
				cnt++;
			}
		}
		
		cout << cnt << endl;
	}
}

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

bool p[1010101];

int main()
{
  memset(p, true, sizeof(p));

  p[0] = p[1] = false;

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

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

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <ctime>
#include <cassert>
#include <iostream>
#include <cctype>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <complex>
#include <fstream>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T> T RoundOff(T a){ return int(a+.5-(a<0)); }
template<class T, class C> void chmax(T& a, C b){ if(a < b) a = b; }
template<class T, class C> void chmin(T& a, C b){ if(b < a) a = b; }
template<class T, class C> pair<T, C> mp(T a, C b){ return make_pair(a, b); }

const int MAX = 1000000;
vector<bool> getPrimeTable(int max)
{
	vector<bool> table(max + 1);
	
	for(int i = 2; i <= max; i++)
	{
		table[i] = true;
		
		for(int j = 2; j * j <= i; j++)
		{
			if(i % j == 0)
			{
				table[i] = false;
				break;
			}
		}
	}
	
	return table;
}

int main()
{
    vector<bool> table(getPrimeTable(MAX));
	
	for(int n; cin >> n && n;)
	{
		int res = table[n - 2];
		
		for(int i = 3; i * 2 <= n; i += 2)
		{
			res += table[i] && table[n - i];
		}
		
		cout << res << endl;
	}
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <sstream>
#include <climits>
#include <cfloat>
#include <complex>

using namespace std;

bool isPrime[1000000];
int main()
{
	fill(isPrime, isPrime+1000000, true);
	for (int i = 2; i < 1000; ++i)
	{
		if (isPrime[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				isPrime[j] = false;
		}
	}

	int n;
	while (scanf("%d", &n), n)
	{
		int ans = 0;
		for (int i = 3; i <= n/2; ++i)
			if (isPrime[i] && isPrime[n-i])
				++ans;
		printf("%d\n", ans);
	}

	return 0;
}

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

const int size = 1000001;
bool a[size];
int n;

void eratos(){
	if(size>=1)
		a[0] = false;
	if(size>=2)
		a[1] = false;
	for(int i=2; i<size; i++)
		a[i] = true;
	for(int i=2; i*i<size; i++)
		if(a[i])
			for(int j=i*i; j<size; j+=i)
				a[j] = false;
}

int main(){
	eratos();
	while(true){
		cin >> n;
		if(!n)
			return 0;
		int ans = 0;
		for(int i=3; i<=n/2; i+=2){
			if(!a[i])
				continue;
			if(a[n-i])
				ans++;
		}
		cout << ans << endl;
	}
}

C++: 
#include <stdio.h>
#include <iostream>
#include <vector>
#include <list>
#include <cmath>
#include <fstream>
#include <algorithm>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <complex>
#include <iterator>
#include <cstdlib>

using namespace std;

#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) (EQ((a).real(),(b).real()) && EQ((a).imag(),(b).imag()))

typedef complex<double> P;
typedef long long ll;

const int MAX_SIZE = 10000;
const int MAX_PRIME = 500000;


int prime[MAX_PRIME+1];
bool isPrime[MAX_PRIME+1];
int p;

void erats(){
	// primeツδ環スツトツづーツ渉可甘コツ可サ
	fill(isPrime,isPrime+MAX_PRIME,true);
	p = 0;
	isPrime[0] = isPrime[1] = false;

	for(int i = 2; i <= MAX_PRIME; i++){
		if(isPrime[i]){
			prime[p++] = i;
		}
		else
			continue;

		// ツづ督づゥツつ「ツづ可つゥツつッツづゥ
		for(int j = 2*i; j <= MAX_PRIME; j+=i){
			isPrime[j] = false;
		}
		cout << flush;
	}
}



int main(){
	erats();
	int n;
	while(cin>>n&&n!=0){
		int cnt=0;
		for(int i = 0; i < p; i++){
			for(int j = i; j < p; j++){
				if(prime[i]+prime[j]==n){
//					cout<<prime[i]<<" "<<prime[j]<<endl;
					cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}

	return 0;
}

C++: #include<stdio.h>
#include<string.h>

char so[1000001];

int main(){
	int n,i,j,count;
	memset(so,0,sizeof(so));
	so[1]=1;
	for(i=2;i<6;i++){
		for(j=2*i;j<=29;j+=i){
			so[j]=1;
		}
	}
	
	for(i=29;i<1000;i+=2){
		if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0)continue;
		for(j=3*i;j<=1000000;j+=(2*i)){
			so[j]=1;
		}
	}

	while(0<=scanf("%d",&n)){
		if(n==0)break;
		count=0;
		for(i=2;i<29;i++){
			if(2*i>n)break;
			if(n-i==3 || n-i==5 || n-i==7 || n-i==11 || n-i==13 || n-i==17 || n-i==19 || n-i==23 || n-i==29){
				if(so[i]==0){
					++count;
					continue;
				}
			}
			j=i;
			i=n-i;
			if(i%2==0 ||i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0){
				i=j;
				continue;
			}
			i=j;
			if(so[i]==0 && so[n-i]==0)++count;
		}
		
		for(i=29;2*i<=n;i+=2){
			if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0)continue;
			j=i;
			i=n-i;
			if(i%23==0 ||i%7==0 || i%3==0 || i%5==0 || i%11==0 || i%13==0 || i%17==0 || i%19==0){
				i=j;
				continue;
			}
			i=j;
			if(so[i]==0 && so[n-i]==0)++count;
		}
		printf("%d\n",count);

	}
	return 0;
}