Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

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

#define maxPN 1000000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
//	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
    int n,num[999999] = {0},i,j,ans;

    while(cin >> n){
        ans = 0;
        for(i = 0;i <= n;i++){
            num[i] = 1;
        }

        for(i = 2;i <= sqrt(n);i++){
            if(num[i]){
                for(j = 0;i * (j + 2) <= n;j++){
                    num[i * (j + 2)] = 0;
                }
            }
        }

        for(i = 2;i <= n;i++){
            if(num[i]){
                ans++;
            }
        }

        cout << ans << endl;
    }
    
    return 0;
}

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

int main()
{
	int n;
	vector<int> prime;

	while (cin >> n) {
		prime.push_back(2);

		for (int I = 2; I <= n; I++) {
			bool isPrime = true;
			for (int i = 0; i < prime.size(); i++) {
				if (I%prime[i] != 0)
					isPrime = false;
			}
			if (isPrime)
				prime.push_back(I);
		}
		cout << prime.size() << endl;
		prime.clear();
	}
	return 0;
}

C++: /*
http://blog.csdn.net/liuke19950717
*/
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
const int maxn= 999999+5;
ll prime[maxn];
int main()
{
	ll cnt=0;
	for(ll i=2;i<maxn;++i)
	{
		if(!prime[i])
		{
			prime[i]=++cnt;
			for(ll j=i*i;j<maxn;j+=i)
			{
				prime[j]=1;
			}
		}
		else
		{
			prime[i]=prime[i-1];
		}
	}
	ll n;
	while(~scanf("%lld",&n))
	{
		printf("%lld\n",prime[n]);
	}
	return 0;
}

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

using namespace std;

const int MAX_N=999999;

bool prime[MAX_N+1];
int p[MAX_N+1];

int main(){
	fill(prime,prime+MAX_N+1,true);
	for (int i=2;i<=MAX_N;i++){
		if (prime[i]){
			for (int j=2*i;j<=MAX_N;j+=i){
				prime[j]=false;
			}
		}
	}
	p[1]=0;
	for (int i=2;i<=MAX_N;i++){
		p[i]=p[i-1]+(prime[i] ? 1 : 0);
	}
	int n;
	while (cin>>n){
		cout<<p[n]<<endl;
	}
	return 0;
}

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

int main() {
	bool isPrime[1000000] = {true};

	for (int i = 0; i < 1000000; i++) {
		isPrime[i] = true;
	}

	cout << endl;
	isPrime[1] = false;
	for (int i = 2; i < 1000000; i++) {
		if (!isPrime[i])
			continue;
		/*
		for (int j = 2; j <= i/j; j++) {
			if (i%j == 0) {
				isPrime[i] = false;
				break;
			}
		}
		*/
		if (isPrime[i]) {
			int k = 2*i;
			while (k < 1000000) {
				isPrime[k] = false;
				k += i;
			}
		}
	}

	int n;
	while (cin >> n) {
		int sum = 0;
		for (int i = 2; i < n; i++) {
			if (isPrime[i])
				sum++;
		}
		cout << sum << endl;
	}

	return 0;
}

C++: #include <stdio.h>
main(n){
	int b[100000],i,j;
	while(~scanf("%d",&n)){
		n++;
		for(i=2;i<n;i++)b[i]=1;
		for(i=2;i<n;i++)for(j=i*2;j<n;j+=i)b[j]=0;
		for(i=2,j=0;i<n;i++)j+=b[i]?1:0;
		printf("%d\n",j);
	}
}

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

C++: #include <iostream>
using namespace std;
 
 
int main()
{
    int max = 10000;
    int prime[max];
    
    fill(prime, prime + max, 1);
    prime[0] = 0;
    prime[1] = 0;
    for (int i = 2; i < max; i++) {
        if (prime[i]) {
            for (int j = 2*i; j < max; j += i) {
                prime[j] = 0;
            }
        }
    }
    
    for(int i = 1;i < max; i++){
	    prime[i] = prime[i] + prime[i-1];
    }
    
    int aaa;
    while (cin >> aaa) {
	cout << prime[aaa] << endl;
    }
    return 0;
}

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

C++: 
/* vo00_09.cpp */

#include <iostream>
using namespace std;

const int N = 1000000;
int prime[N];

void init();

int main()
{
	init();

	int n;
	while (cin >> n) {
		
		cout << prime[n] << '\n';

	}

	return 0;
}

void init()
{
	for (int i = 0; i < N; ++i) { prime[i] = 1; }

	prime[0] = prime[1] = 0;

	int count = 0;
	for (int i = 2; i < N; ++i) {
		if (prime[i]) {
			for (int j = i * 2; j < N; j += i) { prime[j] = 0; }
			count++;
		}
		
		prime[i] = count;
	}
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	while (1) {
		int n;
		int count = 1;
		cin >> n;
		if (n == 1) {
			cout << 0 << endl;
		}
		else if (n == 2) {
			cout << 1 << endl;
		}
		else {
			for (int t = 3; t <= n; t += 2) {
				FOR(i, 2, t - 1) {
					if (t%i == 0) {
						break;
					}
					if (i == t - 1) {
						count++;
						break;
					}
				}
			}
			cout << count << endl;
		}
	}
	
	
	return 0;
}

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

int main() {
	int a;
	while (cin >> a, a) {
		int sosuu = 0;
		if (a > 1)sosuu++;
		if (a > 2)sosuu++;
		for (int b = 5; b <= a; b+=2) {
			for (int c = 3;; c+=2) {
				if (b%c==0)break;
				if ((c + 1)*(c + 1) > b) { sosuu++;   break; }
			}
		}
		cout << sosuu << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	int n;
	bool p[1000000] = { true };
	int ans[1000000] = { 0 };
	p[0] = false;
	p[1] = false;

	for (int i = 2; i < 1000; i++){
		if (p[i]){
			for (int j = i*i; j < 1000000; j+=i){
				p[j] = false;
			}
		}
	}

	for (int i = 0; i < 1000000; i++){
		ans[i] += p[i];
	}

	while (cin >> n)
		cout << ans[n] << endl;

}