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++: //01/12/miya
#include<iostream>
#include<algorithm>
using namespace std;

int main(){
bool p[1000000];
p[0]=false;
p[1]=false;
for(int i=2;i<1000000;i++){
	p[i]=true;
}
for(int i=2; (i*i)<1000000;i++){
	if(p[i]==true){
		for(int y =i+i;y<1000000;y += i){
			if(p[y]==true){
				p[y]=false;
			}
		}
	}
}


while(true){
	int n;
	cin >> n;

	if(n==0)break;
	
	int cnt=0;
	for(int i=0;i<=(n/2);i++){
		if(p[i]==true && p[n-i]==true){
			cnt++;
		}
	}
	cout << cnt << endl;
}	
return 0;
}

C++: #include<iostream>

int n;
const int x = 1000000;
bool prm[x+1];

void eratos(){
	for(int i=2; i<=x; i++)
		prm[i] = true;
	for(int i=2; i*i<x; i++){
		if(prm[i])
			for(int k=i*i; k<=x; k+=i)
				prm[k] = false;
	}
}

int main(){
	int p,q,cnt;
	eratos();
	while(true){
		std::cin >> n;
		if(!n)
			return 0;
		p = 2;
		q = n-p;
		cnt = 0;
		if(prm[p] && prm[q])
			cnt++;
		p++;
		q--;
		for(;p<=q;){
			if(prm[p] && prm[q])
				cnt++;
			p+=2;
			q-=2;
		}
		std::cout << cnt << std::endl;
	}
}

C++: #include <stdio.h>

int main(void)
{
  int n;
  int i, j;
  int is_prime[1000000];
  int cnt;

  for (i = 0; i < 1000000; i++){
    is_prime[i] = 1;
  }

  is_prime[0] = 0;
  is_prime[1] = 0;

  for (i = 0; i * i < 1000000; i++){
    if (is_prime[i] == 1){
      for (j = i + i; j < 1000000; j += i){
        is_prime[j] = 0;
      }
    }
  }

  while (scanf("%d", &n)){
    if (n == 0){
      break;
    }

    cnt = 0;

    for (i = 0; i <= n / 2; i++){
      if ((is_prime[i] == 1) && (is_prime[n - i] == 1)) {
        cnt++;
      }
    }

    printf("%d\n", cnt);
  }

  return (0);
}

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

bool f[(1000001)];
void Cs(){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;}

}
}


int main(){


int c=0,x;
Cs();

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<stdio.h>
int main(){
  int n;
  int i,j,k,sw,c;
  int a[1000001]={};
  a[2]=1;
  j=1;
  for(i=3;i<1000000;i+=2){
    sw=0;
    for(k=2;k*k<=i;k++){
      if(a[k]==1)
	if(i%k==0){
	  sw=1;
	  break;
	}
    }
    if(sw==0)a[i]=1;
  }
  while(1){
    scanf("%d",&n);
    if(n==0)break;
    c=0;
    for(i=2;i<=n/2;i++){
      if(a[i]==1)
	if(a[n-i]==1)
	  c++;
      if(i!=2)i++;
    }
    printf("%d\n",c);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

const int NUM = 1000001;
bool prime[NUM];

void init()
{
    for (int i = 0; i < NUM; i++)
        prime[i] = true;
    prime[0] = prime[1] = false;

    for (int i = 2; i * i < NUM; i++) 
        for (int j = 2 * i; j < NUM; j += i) 
            if (prime[j])
                prime[j] = false;
}

int main()
{
    int n;

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

        for (int i = 2; i <= n - i; i++) 
            if (prime[i] && prime[n - i]) 
                cnt++;

        cout << cnt << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int a[1000000]={1,1},s[500000],c;
int main(){
	r(i,2,100000)
	for(int j=i*2;j<1000000;j+=i)a[j]++;
	r(i,2,1000000)if(!a[i])s[c++]=i;
int n;
while(cin>>n,n){
	int ss=0;
	r(i,0,c){
		if(s[i]>n/2)break;
		if(!a[n-s[i]])ss++;
	}cout<<ss<<endl;
}
}

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

#include <string.h>

using namespace std;

bool prime_check(int n)
{
	if (n == 1) { return false; }

	if (n % 2 == 0)
	{
		if (n == 2) { return true; }

		else { return false; }
	}

	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n % i == 0) { return false; }
	}

	return true;
}

int main()
{
	const int DATA_SETS = 10000;
	const int MAX_PRIME = 1000000;

	int N[DATA_SETS], P[DATA_SETS], C = 0;

	bool I[MAX_PRIME + 1];

	memset(N, 0, sizeof(N));
	memset(P, 0, sizeof(P));
	memset(I, 0, sizeof(I));

	for (int i = 1; i <= MAX_PRIME; i++)
	{
		if (prime_check(i) == true)
		{
			I[i] = true;
		}
		else
		{
			I[i] = false;
		}
	}

	while (true)
	{
		cin >> N[C];

		if (N[C] == 0) { goto Exit; }

		C++;
	}

Exit:;

	for (int i = 0; i < C; i++)
	{
		for (int j = 2; j <= N[i] / 2; j++)
		{
			if (I[j] == true && I[N[i] - j] == true) { P[i]++; }
		}

		cout << P[i] << endl;
	}

	return 0;
}

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

bool isPrime(int n)
{
	int ub = (int)std::sqrt((float)n);
	for (int p=2; p<=ub; p++) {
		if (n%p==0) return false;
	}
	return true;
}

int main()
{
	int n;
	while (true) {
		std::cin >> n;
		if (n == 0) break;
		int res = 0;
		for (int k=3; k<=n/2; k++) {
			if (isPrime(k) && isPrime(n-k)) res++;
		}
		std::cout << res << std::endl;
	}
	return 0;
}

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

int main(){
  int m[1000001]={},j,a,h,t,cou;
  m[2]=1;
  for(int i=3;i<=1000000;i+=2){
    for(j=3;j*j<=i;j++){
      if(i%j==0)break;
    }
    if(j*j>i)m[i]=1;
  }
  while(1){
    cin >> a;
    if(a==0)break;
    h=0;
    cou=0;
    while(1){
      for(h++;m[h]!=1&&h<=a;h++);
      if(h>a/2)break;
      if(m[a-h]==1)cou++;
    }
    cout << cou << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;
bool IsPrime[1000001];

void calc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for(int i = 2; i < 1000001; ++i)
	{
		if(IsPrime[i])
		{
			for(int j = 2 * i; j < 1000001; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	while(cin >> n, n)
	{
		int count = 0;
		int temp = n / 2;
		for(int i = 0; i <= temp; ++i)
		{
			if(IsPrime[i] == 1 && IsPrime[n - i] == 1)
			{
				count++;
			}
		}
		cout << count << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

bool judgePrimeNumber( int a )
{
    for( int i = 2; i <= sqrt(a); i++ )
        if( a % i == 0 )
            return false;
    return true;
}

int main()
{
    int n;
    bool a[1000000];
    
    a[0] = a[1] = false;
    for( int i = 2; i < 1000000; i++ )
        a[i] = judgePrimeNumber(i);

    while( cin >> n )
    {
        if( !n )
            break;

        int cnt = 0;
        for( int i = 2; i <= n / 2; i++ )
            if( a[i] && a[n-i] )
                cnt++;
            
        cout << cnt << endl;
    }

    return 0;
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    for(int i=3;i<=999991;i++){
	bool flg = true;
	for(int j=0;primes[j]*primes[j] <= i;j++){
	    if(i % primes[j] == 0){
		flg = false;
		break;
	    }
	}
	if(flg) primes.PB(i);
    }
    while(true){
	int n;
	cin >> n;
	if(n == 0) break;
	int ans = 0;
	for(int i=0;primes[i]<=n/2;i++){
	    int j = lower_bound(ALL(primes),n-primes[i]) - primes.begin();
	    if(primes[j] + primes[i] == n) {
		ans++;
	    }
	}
	cout << ans << endl;
    }
    return 0;
}