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

bool primeFlg[1000000];

void makePrime(){
  memset(primeFlg, true, sizeof(primeFlg));
  primeFlg[0] = primeFlg[1] = false;
 
  for(int i = 2; i * i <= 1000000; i++){
    if(primeFlg[i]){
      for(int j = i + i; j < 1000000; j += i){
        primeFlg[j] = false;
      }
    }
  }
}

int main(){
  makePrime();

  int n;

  while(cin >> n, n){
    int answer = 0;

    for(int i = 2; i < n; i++){
      int j = n - i;

      if(i <= j && primeFlg[i] && primeFlg[j]){
        answer++;
      }
    }

    cout << answer << endl;
  }
}

C++: #include <iostream>

using namespace std;
main(){
  int prime[100000];
  bool is_prime[1000001];
  int p=0;
  for(int i=0;i<=1000000;i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<=1000000;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=1000000;j+=i) is_prime[j]=false;
    }
  }
  prime[p]=-1;
  int n;
  while(1){
    cin >> n;
    if(n==0) break;
    int ans=0;
    for(int i=0;i<1000000;i++){
      if(prime[i]==-1) break;
      if(prime[i]>n) break;
      int tmp=n-prime[i];
      if(tmp>=prime[i]){
	if(is_prime[n-prime[i]]) ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

int prime[STA+1];

int main(){
  int n;
  int cnt;
  for(int i=2;i<=STA/2;i++){
    for(int j=2;i*j<=STA;j++){
      prime[i*j] = 1;
    }
  }
  while(1){
    cnt = 0;
    cin >> n;
    if(n == 0) break;
    for(int i=2;i<=n/2;i++){
	if(prime[i] == 0 && prime[n-i] == 0) cnt++;
    }
    cout << cnt << endl;
  }
}

C++: #include<stdio.h>
#include<iostream>
#include<string>
#include<algorithm>
#include <vector>
#include<math.h>


using namespace std;

bool f[10000002];
int N=1000000;
int main () {
  for(int i=3;i<=N;i+=2){f[i]=true;
	  for(int j=3;j*j<=i;j+=2)
		  if(i%j==0)f[i]=false;
  }
  int x;
  while(1){

  int ans=0;
  cin>>x;if(x==0)break;
  for(int i=3;i<=x/2;i+=2)
	  if(f[x-i]==true&&f[i]==true)ans++;//cout<<i<<" "<<x-i<<endl;//
	  
  cout<<ans<<endl;
}
  return 0;
}

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

int sosu[500000];
int scmax,sosumi;

void setsosu(int n){
  int flg,j;
  if (n<scmax) return;
  for (int i=scmax+1;i<=n;i++){
    flg=0;
    for (j=sosu[0];j<=sqrt(i);j++){
      //cout << i << " " << j << " " << i%j << endl;
      if (i%j==0){flg =1;break;}
    }
    if (flg==0) sosu[++sosumi]=i;
  }
  scmax =n;
}
int nibutan(int n){
  int l,r,m;
  l=0;
  r=sosumi+1;
  while (l<r){
    m=(l+r)/2;
    if (sosu[m]>n){
      r=m;
    }else if (sosu[m]<n){
      l=m+1;
    }else{
      return 1;
    }
  }
  return 0;
}
int main(){
  int n,ret;
  sosu[0]=2;
  sosu[1]=3;
  sosu[2]=5;
  sosu[3]=7;

  scmax=7;
  sosumi=3;

  while (1){
    cin >> n;
    if (n==0) break;
    ret =0;
    setsosu(n);
    for (int i=sosu[1];i<=n/2;i+=2){
      if (nibutan(i)==1&&nibutan(n-i)==1) {
	ret++;
	//cout << i <<" "<< n-i << endl;

      }
    }
    cout << ret << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  bool num[1000001] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j= i*i; j<1000001; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n,n){
    int ans = 0;
    for(int i=3; i<=n/2; i+=2){
      if((!num[i]) && (!num[n-i])){ans++;}
    }
    cout <<ans<<endl;
  }
  return 0;
}

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

int main(){
    bool nonPrime[1000001] = {};
    nonPrime[0] = nonPrime[1] = true;
    vector<int> prime;
    
    for(int i = 2; i <= 1000000; i++){
        if(!nonPrime[i]){
            prime.push_back(i);
            for(int j = i+i; j <= 1000000; j+=i){
                nonPrime[j] = true;
            }
        }
    }

    //for(int p : prime)  cout << p << endl;

    int n;
    while(1){
        cin >> n;
        if(n == 0)  break;

        int ans = 0;
        for(int p : prime){
            if(p > n)   break;
            if(!nonPrime[n-p])  ans++;
        }
        
        cout << (ans+1) /2<< endl;
    }

    return 0;
}

C++: #include<stdio.h>
#include<bitset>
int main()
{
	const int N=1000001;
	int i,j,n,c;
	std::bitset<N>p;
	p.set();
	for(i=2;i*2<N;++i)if(p[i])for(j=2*i;j<N;j+=i)p[j]=0;
	while(scanf("%d",&n),n)
	{
		for(c=0,i=j=n/2;i>1;--i,++j)if(p[i]&&p[j])c++;
		printf("%d\n",c);
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int prime[200];
int main(){
	int count=0;
	for(int i=3;i<1000;i+=2){
		bool t=true;
		for(int j=0;j<count;j++)
			if(i%prime[j]==0)t=false;
		if(t==true){
			prime[count]=i;
			count++;
		}
	}
	int n;
	while(true){
		cin>>n;
		if(n==0)
			break;
		n/=2;
		int ans=0,k=n*2-3;
		bool t;
		for(int i=3;i<=n;i+=2){
			t=true;
			for(int j=0;j<count;j++){
				if(i%prime[j]==0){
					if(i!=prime[j]){
						t=false;
						break;
					}
				}
				if(k%prime[j]==0){
					if(k!=prime[j]){
						t=false;
						break;
					}
				}
			}
			if(t)ans++;
			k-=2;
		}
		cout<<ans<<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
bool isp[1<<20];
main()
{
    for(int i=2;i<1<<20;i++)isp[i]=1;
    for(int i=2;i<1<<20;i++)
    {
        if(!isp[i])continue;
        for(int j=i+i;j<1<<20;j+=i)isp[j]=0;
    }
    int n;
    while(cin>>n,n)
    {
        int cnt=0;
        for(int i=2;i*2<=n;i++)
        {
            cnt+=isp[i]&&isp[n-i];
        }
        cout<<cnt<<endl;
    }
}

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]){
	j = n - i;
	if(p[j]) count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
#define NN 1000001;

int main(){

bool f[(1000001)];
int c=0,x;

for(int i=3;i<1000001;i+=2)
f[i]=true;

for(int i=3;i<1000001;i+=2)
for(int j=3;j<=sqrt((double)(i));j+=2)
{if(i%j==0){f[i]=false;break;}

}
while(1){
scanf("%d",&x);if(x==0)break;
for(int i=3;i<x;i+=2)
for(int j=x-1;j>=i;j-=2)
	if((f[i]==true&&f[j]==true)&&i+j==x){printf("%d+%d\n",i,j);c++;}

printf("%d\n",c);
c=0;
}
return 0;
}

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 p[1000000];
int main()
{
	for (int i = 2; i < 1000000; ++i)
	{
		if (!p[i])
		{
			for (int j = 2*i; j < 1000000; j += i)
				p[j] = true;
		}
	}

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

	return 0;
}

C++: #include<stdio.h>
int prime[1000001];
int main(){
	prime[0]=prime[1]=-1;
	for(int i=2;i<=1000000;i++){
		if(prime[i]!=-1){
			prime[i]=1;
			for(int j=i+i;j<=1000000;j+=i)prime[j]=-1;
		}
	}
	int a;
	while(scanf("%d",&a),a){
		int ret=0;
		for(int i=1;i<=a/2;i++)if(prime[i]==1&&prime[a-i]==1)ret++;
		printf("%d\n",ret);
	}
}