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 "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _overload4(_1,_2,_3,_4,name,...) name
#define _overload3(_1,_2,_3,name,...) name
#define _overload2(_1,_2,name,...) name
#define _rep(i,n) _repi(i,0,n)
#define _repi(i,a,b) for(ll i=a;i<b;++i)
#define _repc(i,a,b,c) for(ll i=a;i<b;i+=c)
#define rep(...) _overload4(__VA_ARGS__,_repc,_repi,_rep)(__VA_ARGS__)
#define _rrepi(i,a,b) for(ll i=b-1;i>=a;i--)
#define _rrep(i,n) _rrepi(i,0,n)
#define _rrepc(i,a,b,c) for(ll i=a+(b-a-1)/c*c;i>=a;i-=c)
#define rrep(...) _overload4(__VA_ARGS__,_rrepc,_rrepi,_rrep)(__VA_ARGS__)
#define sum(...) accumulate(range(__VA_ARGS__),0)
#define _range(i) (i).begin(),(i).end()
#define _rangek(i,k) (i).begin(),(i).begin()+k
#define range(...) _overload2(__VA_ARGS__,_rangek,_range)(__VA_ARGS__)
#define LINF (ll)1000000000000000000
#define MOD (ll)1000000007
#define INF (int)1000000007
#define Yes(i) out(i?"Yes":"No")
#define YES(i) out(i?"YES":"NO")
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define STR(...) string __VA_ARGS__;in(__VA_ARGS__)
#define CHR(...) char __VA_ARGS__;in(__VA_ARGS__)
#define DBL(...) double __VA_ARGS__;in(__VA_ARGS__)
#define vec(type,name,size) vector<type> name(size);
#define VEC(type,name,size) vector<type> name(size);in(name)
struct aaa{aaa(){cin.tie(0); cout.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}aaaaaaa;
inline void in() {}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec);
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p);
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec);
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p);
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){for(T& x: vec) is >> x;return is;}
template<typename T,typename L>
istream& operator >> (istream& is, pair<T,L>& p){is >> p.first;is >> p.second;return is;}
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){os << vec[0];rep(i,1,vec.size()){os << ' ' << vec[i];}return os;}
template<typename T,typename L>
ostream& operator << (ostream& os, pair<T,L>& p){os << p.first << " " << p.second;return os;}
template <class Head, class... Tail>
inline void in(Head&& head,Tail&&... tail){cin>>head;in(move(tail)...);}
template <class T>
inline void out(T t){cout<<t<<'\n';}
template <class Head, class... Tail>
inline void out(Head head,Tail... tail){cout<<head<<' ';out(move(tail)...);}

bool prime[1000001];
int main(){
    prime[0]=prime[1]=1;
    rep(i,2,1000001){
        if(!prime[i])for(ll j=i<<1;j<1000001;j+=i)prime[j]=1;
    }
    int n;
    while(cin>>n,n){
        int ans=0;
        rep(i,3,n/2+1,2)if(!prime[i]&&!prime[n-i])ans++;
        out(ans);
    }
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    bool prime[1000001];
    for(int i=2;i<1000001;i++)prime[i]=true;
    for(int i=2;i<=sqrt(100000);i++){
        if(prime[i]==true){
            for(int j=i+i;j<1000001;j+=i)prime[j]=false;
        }
    }
    int n,cou=0;
    while(cin>>n&&n!=0){
        for(int i=2;i<=n/2;i++)if(prime[i]==true&&prime[n-i]==true)cou++;
        cout<<cou<<endl;
    cou=0;
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
int main() {

	bool table[1000001];
	fill((bool*) table, (bool*) table + 1000001, true);

	table[0] = false;
	table[1] = false;
	for (int i = 2; i * i <= 1000000; i++) {
		if (table[i]) {
			for (int j = i + i; j <= 1000000; j += i) {
				table[j] = false;
			}
		}
	}

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

		int res = 0;
		for (int i = n, j = 0; j <= n / 2; j++, i--) {
			if (table[i] && table[j])
				res++;
		}

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

C++: #include <iostream>
using namespace std;
#define MAX_N 1000001
int main(){
  int n;
  int isPrime[MAX_N];
  fill(isPrime,isPrime + MAX_N,1);

  isPrime[0] = isPrime[1] = 0;

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

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

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

using namespace std;

int main(void){
	int n;
	bool isp[1000001];
	
	//但多
	memset(isp,true,sizeof(isp));
	isp[0] = false;
	isp[1] = false;
	for(int i=2;i<1000001;i++){
		if(isp[i]){
			for(int j=2;i*j<1000001;j++){
				isp[i*j] = false;
			}
		}
	}
	
	while(cin >> n && n){
		int ret=0;
		for(int i=2;i<=n/2;i++){
			if(isp[i] && isp[n-i]) ret++;
		}
		cout << ret << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

void makePrimeNumber(int N, vector<bool>& prime) // 0ツ暗按湘」Nツ暗按可コツづ個青ョツ青板つゥツづァツ素ツ青板づーツ探ツつキ
{
    prime.assign(N+1, true);
    prime [0] = prime[1] = false;
    for(int i=2; i*i<=N; i++){
        if(prime[i]){
            for(int j=i; i*j<=N; j++){
                prime[i*j] = false;
            }
        }
    }
}

int main()
{
    vector<bool> prime;
    makePrimeNumber(50000, prime);

    vector<int> num;
    for(int i=0; i<=50000; ++i){
        if(prime[i])
            num.push_back(i);
    }

    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        int ret = 0;
        for(unsigned i=0; num[i]<=n/2; ++i){
            if(prime[n-num[i]])
                ++ ret;
        }
        cout << ret << endl;
    }
}

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

int main()
{
  bool pri[1000001];
  vector<int> price;
  fill(pri,pri+1000001,true);
  pri[0]=pri[1]=false;
  for(int i=2;i<1000001;i++)
    {
      if(pri[i]==0)
	continue;
      price.push_back(i);	
      for(int j=i+i;j<1000001;j+=i)
	{
	  pri[j]=false;
	}
    }
  int n;
  for(;cin>>n,n;)
    {     
      int count=0;

      for(int i=0;i<price.size();i++)
	{
	  for(int j=i;j<price.size();j++)
	    {
	      if(price[i]+price[j]==n)
		count++;
	      if(price[j]>=n)
		break;
	    }
	  if(price[i]>=n)
	    break;
	}
      cout<<count<<endl;
    
    }
 
}

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

vector<int>primes(1000001);
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes[i] = true;
		}
	}
	flag = true;
}

int main() {
	hurui(1000000);
	while (1) {
		int N; cin >> N;
		if (!N)break;
		int ans = 0;
		for (int i = 2; i <= N / 2; ++i) {
			if (primes[i] && primes[N - i])ans++;
		}
		cout << ans << endl;
	}
	return 0;
}