Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

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


/*
	HOME-  Volume0-0009
	Submit Statistics
	 
	PCK 2003
	Prime Number
	Time Limit : 1 sec, Memory Limit : 32768 KB
	English version is here
	Prime Number

	6 ÈºÌ³Ì® n ðüÍµAn ÈºÌfª¢­Â é©ðoÍ·évOðì¬µÄº³¢B½¾µAfÆÍ 1 Æ©ª©gÅµ©èØêÈ¢³Ì®Ì¤¿ 1 ðÌ¼¢½àÌð¢¢Ü·Bá¦Î 10 ÈºÌfÍA2, 3, 5, 7 Å·B
	Input

	¡Ìf[^Zbgª^¦çêÜ·Bef[^ZbgÉ n ªPsÉ^¦çêÜ·BüÍÌÅãÜÅµÄº³¢B
	Output

	ef[^Zbg²ÆÉAn ÈºÌfÌÂðPsÉoÍµÄº³¢B
	Sample Input

	10

	Output for the Sample Input

	4

*/

using namespace std;


int main()
{
	string s;
	
	while (getline(cin, s))
	{
		int n;
		sscanf(s.c_str(), "%ld", &n);
		
		vector<int> v(n, 1);
		v[0] = 0;
		v[1] = 0;

		int x = n - 2;

		for (int i = 2; i <= n; i++)
		{
			if (0 == v[i])
			{
				continue;
			}
			for (int k = i * i; k <= n; k++)
			{
				if (0 == (k % i))
				{
					if (1 == v[k])
					{
						x--;
					}
					v[k] = 0;
				}
			}
		}
		
		printf("%d\n", x);
	}

	return 0;
}

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

bool isPrime(int k) {
    for(int i = 2; i < k; i++){
        if(k%i == 0) 
            return false;
    }
    return true;
}

int main() {
    int n;
    int count = 0;
    while(cin>>n) {
        for(int i = 2; i <= n;i++) {
            if(isPrime(i))
                count++;
        }
        cout<<count<<endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
int main()
{
	int n;
	while(scanf("%d",&n)!=EOF)
	{
		int count=0;
		for(int prime=2; prime<=n; prime++)
		{
			if(prime==2)
			{
				count++;
			}
			else
			{
				int i;
				for(i=2; i<prime; i++)
				{
					if(prime%i==0)
						break;
				}
				if(i==prime)
					count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

C++: #include <iostream>

#define rep(i, n) for(int i = 2; i < n; i ++)

using namespace std;

int main(void){
	const int N = (int)1e6;
	bool num[N];
	rep(i, N) num[i] = true;
	for(int i = 2; i * i < N; i ++) if(num[i]) for(int j = i; i * j < N; j ++) num[i * j] = false;

	for(int n, count = 0; cin >> n; cout << count << endl, count = 0)
		rep(i, n + 1) if(num[i]) count ++;

	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <cstring>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --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 all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

bool num[MAXNUM];
void erast(int n){
  FOR(i, 2, floor(sqrt(n))+1){
    if(num[i]){
      FOR(j, 2, n){
        if(i*j>=MAXNUM) break;
        num[i*j] = false;
      }
    }
  }
}

int main(){
  int n;
  REP(i, MAXNUM)  num[i] = true;
  num[0]=false;
  num[1]=false;
  while(cin >> n){
    int ans=0;
    erast(n);
    REP(i, n+1){
      if(num[i]){
        ans++;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define pb push_back

using namespace std;

const int MAX=100000;
int main(void)
{
	int x;
	bool p[MAX];
	int cnt;
	int i1,i2;

	fill(p,p+MAX,false);

	for(i1=2;i1<MAX;i1++){
		for(i2=2;i2*i2<=i1;i2++){
			if(i1%i2==0) break;
		}
		if(i2*i2>i1) p[i1]=true;
	}

	while(1){
		cin>>x;
		if(x==EOF) break;

		cnt=0;
		for(i1=0;i1<=x;i1++){
			if(p[i1]) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

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

int main()
{
	bool num[1000000] ;
	for( int i = 0 ; i < 1000000 ; i ++ )
	{
		num[i] = false ;
	}

	int count = 0 ;
	int get ;
	while( cin >> get )
	{
		for( int i = 2 ; i <= get ; i ++ )
		{
			if( num[i] == false )
			{
				for( int j = 1 ; j < (get/i) ; j ++ )
				{
					num[i+(j*i)] = true ;
				}

				count ++ ;
			}
		}
		cout << count << endl ;
		count =  0 ;

		for( int i = 0 ; i < get ; i ++ )
		{
			num[i] = false ;
		}
	}

	return 0 ;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --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 all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

int num[MAXNUM]={0};

int main(){
  int n;
  while(cin >> n){
    vector<int> vec;
    vec.push_back(2);
    for(int i = 3; i<=n; i+=2){
      if(num[i]==1) continue;
      FOR(j, 2, MAXNUM){
        if(i*j>n)  break;
        num[i*j]=1;
      }
      vec.push_back(i);
    }
    cout << vec.size() << endl;
  }
  return 0;
}

C++: 
#include <cstdio>
#include <iostream>
using namespace std;
int list[1000000],p[80000];
int sum[1000000];

void gets()
{
    p[0]=2;
    int key=0;
    for(int i=0;i<1000000;i++)
        list[i]=i%2;
    for(int i=3;i<1000000;i+=2)
        if(list[i])
    {
        p[++key]=i;
        for(int j=2*i;j<1000000;j++)
            list[j]=0;
    }
}

int main()
{
    gets();
    for(int i=0;i<1000000;i++)
        sum[i]=0;
    for(int i=0;i<80000;i++)
        sum[p[i]]=1;
    for(int i=1;i<1000000;i++)
        sum[i]+=sum[i-1];
    int n;
    while(cin>>n)
        cout<<sum[n]<<endl;
    return 0;
}

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

bool prime[STA];

int main(){
    memset(prime,true,sizeof(prime));
    for(int i=2;i<STA;i++){
        for(int j=2;i*j<STA/2;j++) prime[i*j] = false;
    }
    int n;
    while(cin >> n){
        int cnt = 0;
        for(int i=2;i<=n;i++){
            if(prime[i]) cnt++;
        }
        cout << cnt << endl;
    }
}

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

#define MAX_NUM (1000000)

int main(void)
{
  static bool searchList[MAX_NUM];
  static bool isPrime[MAX_NUM];
  static int primeNum[MAX_NUM];
  
  double maxSq = sqrt((double)(MAX_NUM - 1));
  
  for (int i = 2; i <= maxSq + 1; i++) {
    if (!searchList[i]) {
      isPrime[i] = true;
      for (int j = 2; j < MAX_NUM; j++) {
        if (j % i == 0) {
          searchList[j] = true;
        }
      }
    }
  }
  
  for (int i = maxSq + 2; i < MAX_NUM; i++) {
    if (!searchList[i]) {
      isPrime[i] = true;
    }
  }
  
  
  for (int i = 2; i < MAX_NUM; i++) {
    primeNum[i] = isPrime[i] ? primeNum[i - 1] + 1 : primeNum[i - 1];
  }
  
  int n;
  while (std::cin >> n) {
    std::cout << primeNum[n] << std::endl;
  }
  
  return 0;
}