#include <iostream>
using namespace std;
int pri[50001];

int main(){
  int prime[100000];
  fill(prime,prime + 100000,1);
  prime[0] = prime[1] = 0;
  for(int i = 2 ; i*i < 100000 ;i++ ){
    if(prime[i])for(int j = i*2 ; j < 100000 ;j+=i )prime[j] = 0;
  }

  int p = 0;

  for(int i = 0 ; p < 50001 ; i++){
    if(prime[i])pri[p++] = i;
  }

  int ans[50100];
  for(int i = 0 ; i < 50100 ; i++)ans[i] = 0;

  for(int i = 0 ; i <= 50000 ; i++ ){
    for(int j = i ;  pri[i] + pri[j] <= 50000 ; j++){
      ans[pri[i] + pri[j]]++;
    }
  }
  int n;
  while( cin >> n,n ){
    cout << ans[n] << endl;
  }
  return 0;
}