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

#define MAX 1000000
#define sqrtMAX sqrt(MAX)

int main(void)
{
  int n;
  vector<int> b(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;

  while(scanf("%d", &n)!=EOF) {
    if(n==0)
      break;
    count = 0;
    for(i=0;i<n/2;i++)
      if(!b[i]&&!b[n-i]) count++;
    printf("%d\n", count);
  }
  return 0;
}

C++: #include <cstdio>
#include <cmath>
using namespace std;
bool isprime(int n)
{
    for (int i=3; i*i<=n; i+=2) {
        if (n%i==0) return false;
    }
    return true;
}
int main()
{
    int n;
    while (scanf("%d",&n)&&n!=0) {
        int res=0;
        for (int i=3; i<=n/2; i+=2) if (isprime(i)&&isprime(n-i)) res++;
        printf("%d\n",res);
    }
}

C++: #include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define SORT(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define EQ(a,b) (abs((a)-(b))<eps)
bool prime[1000100];
void eratos()
{
	memset(prime,true,sizeof(prime));
	prime[0]=prime[1]=false;
	for(int i=2;i*i<=1000000;i++)
	{
		if(prime[i])for(int j=i*2;j<=1000000;j+=i)
		{
			prime[j]=false;
		}
	}
	return;
}
int main()
{
	eratos();
	while(1)
	{
		int n;
		cin >> n;
		if(n==0)break;
		int cnt = 0;
		for(int i=2;i<=n/2;i++)if(prime[i]&&prime[n-i])cnt++;
		cout << cnt << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
using namespace std;

const int INF = 1e9;
typedef long long ll;
#define MAX_N 1000001

int n;
bool isPrime[MAX_N];

void init(){
  for(int i = 0; i <= MAX_N; i++) isPrime[i] = true;
  isPrime[0] = isPrime[1] = false;
  for(int i = 2; i * i <= MAX_N; i++){
    if(isPrime[i]) for(int j = i * i; j <= MAX_N; j += i){
      isPrime[j] = false;
    }
  }
}

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

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

bool is_prime[1000001];
int prime[1000001];
int main() {
	memset(is_prime, 1, sizeof(is_prime));
	is_prime[0] = is_prime[1] = false;
	int p = 0;
	for (int i = 2; i <= 1000000; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = i * 2; j <= 1000000; j += i)is_prime[j] = false;
		}
	}
	int n;
	while (scanf("%d", &n), n) {
		int cnt = 0;
		for (int i = 0; prime[i] <= n / 2; i++) {
			if (is_prime[n - prime[i]])cnt++;
		}
		printf("%d\n", cnt);
	}
}

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

int main() {
    bool is_prime[1000001];
    for (int i = 0 ; i < 1000001; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= 1000000 / 2; i++) {
        if (is_prime[i])
            for (int j = 2; j * i <= 1000000; j++) {
                is_prime[i*j] = false;
            }
    }
    int N;
    while (cin >> N, N) {
        int count = 0;

        for (int i = 0; i <= N / 2; i++) {
            if (is_prime[i] && is_prime[N-i]) {
                count++;
            }
        }

        cout << count << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define sup 1000000
using namespace std;
std::vector<int> prm;
/*
inline bool isinthevector(std::vector<int> v,int n)
{
	std::vector<int>::iterator i=find(v.begin(), v.end(),n);
	return i!=v.end();
}
*/

inline bool isprmfunc(int n)
{
	for (int i = 0; prm[i]*prm[i]<=n; ++i)
	{
		if(n%prm[i]==0) return false;
	}
	return true;
}

int main(int argc, char const *argv[])
{
	prm.push_back(2);
	prm.push_back(3);
	bool isprm=true;
	for(int n=5;n<=sup;n+=2,isprm=true)
	{
		for (int i=0;prm[i]*prm[i]<=n;++i)
		{
			if(n%prm[i]==0)
			{
				isprm=false;
				break;
			}
		}
		if (isprm==true)
		{
			prm.push_back(n);
		}
	}

	int n;
	while(cin>>n,n)
	{
		int cnt=0;
		for (int i=0;2*prm[i]<=n;++i)
		{
			if (isprmfunc(n-prm[i]))
			{
				++cnt;
			}
		}
		cout<<cnt<<"\n";
	}
	return 0;
}

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

int f[500000],s[42000];

int main() {
   int n,i,j,k=0;
   for (i=2;i<500000;i++) if (f[i]==0) {
	   f[i]=1; s[k++]=i;
	   for (j=i+i;j<500000;j+=i) f[j]=2;
   }
   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<bits/stdc++.h>
using namespace std;
int sosu[1000005]={0};
main(){
  int n;
  sosu[2]=0;
  sosu[1]=1;
  sosu[0]=1;
  for(int i=3;i<=sqrt(1000000);i+=2){
    if(sosu[i]==0){
      for(int j=i*2;j<=1000000;j+=i){
	sosu[j]=1;
      }
    }
  }
  while(cin>>n,n){
    int l,r;
    l=3;
    r=n-3;
    int cnt=0;
    while(l<=r){
      //cout<<l<<" "<<r<<endl;
      if(!sosu[l]&&!sosu[r]){
	//cout<<"A"<<l<<" "<<r<<endl;
	cnt++;
      }
      r-=2;
      l+=2;
    }
    cout<<cnt<<endl;
  }
}

C++: #include <iostream>
#include <cmath>

using namespace std;

int const N = 1000000;

int ps[N+1];
int cnt[N+1]={};

bool isp[N+1]={};

int idx=0;
inline void add(int n){
    ps[idx++]=n;
}

void init(){
    for(int i=0; i<=N; i++) isp[i]=true;
    add(2);
    for(int i=4; i<=N; i+=2) isp[i]=false;
    for(int i=3; i<=N; i+=2){
        if(!isp[i]) continue;
        add(i);
        for(int j=i+i; j<=N; j+=i) isp[j]=false;
    }
}

int main(){
    init();

    int n;
    while(cin>>n, n){
        int ans = 0;
        for(int i=0; i<idx; i++){
            if(n-ps[i]<0 || ps[i] > n-ps[i]) break;
            if(isp[n-ps[i]]) ans++;
        }
        cout << ans << endl;
    }
}