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  <iostream >
    using  namespace  std;

    int  main()
    {
    	
    	for (int i=0; i<=30; i++)
    	{
    	
        int  N;
        cin  >>  N;
        
        
        int count = 0;
        for (int  i =  1;  i <= N;  ++i)
        {
            bool  isPrime  =  true ;
            for (int  j =  2;  j < i;  ++j)
            {
                if (i  % j ==  0)
                {
                    isPrime  =  false ;
                    break ;
                }
            }
            if (isPrime)
            {
                --N;
                count++;
                
            }
        }
    
        cout << count << endl;
		}
        return  0;
    }

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

const int MAX_N = 999999;
bool prime[MAX_N + 1];

void sieve()
{
  prime[0] = prime[1] = false;
  for(int i = 2; i <= MAX_N; ++i)
    prime[i] = true;
  for(int i = 2; i <= MAX_N; ++i)
    if(prime[i])
      for(int j = i * 2; j <= MAX_N; j += i)
	prime[j] = false;
}

int is_prime(int n)
{
  return prime[n];
}

int main()
{
  int n, i;
  int ans;
  sieve();
  while(cin >> n){
    ans = 0;
    for(i = 1; i <= n; i++){
      if(is_prime(i)){
	ans++;
      }
    }
    printf("%d\n", ans);
  }
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

const int MAX_N = 1000000;

bool sieve[MAX_N];
int num[MAX_N];

int main()
{
  memset(sieve, true, sizeof sieve);

  sieve[0] = sieve[1] = false;
  int n = 0;
  for (int i = 2; i < MAX_N; i++) {
    if (sieve[i]) {
      n++;
      for (int j = 2 * i; j < MAX_N; j += i) {
        sieve[j] = false;
      }
    }
    num[i] = n;
  }

  int a;
  while (scanf("%d", &a) != EOF) {
    printf("%d\n", num[a]);
  }

  return 0;
}

C++: #include <cstdio>
#define MAX 1000

int main(){
	int n;
	bool c[MAX]={true};
	int t[MAX];t[0] = 0;
	for(int i = 2;i < MAX;i++){
		for(int j = i;i*j < MAX;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 15;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
??
#define Max 1000000
??
int prime [10000000];
	??
int main()
{
	????????int n, out;
	??
		????????for (int i = 2; i * i < Max; i++){
			????????????????if (prime[i] == 0){
				????????????????????????for (int j = i; j < Max; j += i){
					????????????????????????????????if (!(j == i)) prime[j] = 1;
					????????????????????????}
				????????????????}
			????????}
	??
		????????while (cin >> n){
			????????????????out = 0;
			????????????????for (int i = 0; i <= n; i++){
				????????????????????????if (prime[i] == 0) out++;
				????????????????}
			????????????????cout << out - 2 << endl;
			????????}
	????????return(0);
}

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

int main(){
  int n,prime[1000000],key,lf=0;
  prime[0]=2;
  key=1;
  for(int i=3;i<=999999;i+=2)
    {
      for(int j=2;j<=sqrt(i);j++)
	{
	  if(i%j == 0)
	    {
	      lf=1;
	      break;
	    }
	}
      if(lf == 1)
	{
	  lf=0;
	}
      else 
	{
	  prime[key]=i;
	  key++;
	}
    }

  while(cin >> n)
{
  int cou=0;
  for(int i=0;;i++)
    {
      if(prime[i] <= n)
	{
	  cou++;
	}
      else break;
    }

  cout << cou << endl;
 }
}

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

int main()
{	
	bool p[MAX];
	fill(p, p + MAX, 1);
	
	p[0] = p[1] = 0;
	for (int i = 2; i < sqrt(MAX) + 1; i++) {
		if (p[i]) {
			for (int j = i * 2; j < MAX; j += i)
				p[j] = 0;
		}
	}
	
	int n;
	while (cin >> n) {
		int sum = 0;
		while(n) sum += p[n--];
		cout << sum << endl;;
	}
		
	return 0;
}

C++: #include <stdio.h>
#include <stdbool.h>

int main(void)
{
  bool isPrime[1000000];
  int i,j;
  for(i=2; i<1000000; ++i){
    isPrime[i] = true;
  }
  int primeCount[1000000];

  for(i=2; i<1000000; ++i){
    if(isPrime[i]){
      primeCount[i] = primeCount[i-1]+1;
      if(i<1000){
        for(j=i*2; j<1000000; j+=i){
          isPrime[j] = false;
        }
      }
    }else{
      primeCount[i] = primeCount[i-1];
    }
  }
        
  int n;
  while(scanf("%d", &n) != EOF){
    printf("%d\n", primeCount[n]);
  }

  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#define INF 999999
using namespace std;

int main()
{
	int n, rootn,ans=0;
	bool a[INF] = {true};
	while (cin >> n)
	{
		rootn = sqrt(n);
		for (int i = 2; i <= rootn; i++)
		{
			for (int j = 0; j < INF; j++)
			{
				if (j%i == 0) a[j] = false;
			}
		}
		for (int i = 0; i < INF; i++)
		{
			if (a[i])++ans;
		}
		cout << ans << endl;
	}
			
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>

using namespace std;

int HowManyPrimeNumbers1(const int);
int HowManyPrimeNumbers2(const int);

int main(){
	int n;

	while(cin >> n){
		printf("%d\n",HowManyPrimeNumbers1(n));
	}

	return 0;
}

int HowManyPrimeNumbers1(const int n){
	int i,j,buf,cnt = 1;

	for(i=3;i<=n;i+=2){
		buf = (int)sqrt((double)i);

		for(j=3;j<=buf;j+=2){
			if((i % j) == 0){
				cnt--;
				break;
			}
		}

		cnt++;
	}

	return cnt;
}

int HowManyPrimeNumbers2(const int n){
	return n;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n , i , j;
	while(cin >> n ){
		int counter = 0;
		for( int i=1 ; i<=n ; i++ ){
			int temple=0;
			for( int j=1 ; j<=n ; j++ ){
				if( i%j == 0 )
					temple++;
			}
			if( temple == 2 )
				counter ++;
		}
		cout << counter << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <functional>

class Mod{
	const int n;
	public:
		Mod(const int _n):n(_n){}
		bool operator()(const int _src){
			return ! (_src % n);
		}
};

const std::vector<int> Eratosthenes(std::vector<int>& src){
	std::vector<int> result;
	int cnt(0);
	while(!src.empty()){
		int n(src[0]);
		result.push_back(n);
		Mod mod(n);
		std::vector<int>::iterator it= std::remove_if( src.begin(), src.end(), mod );
		src.erase(it,src.end());
		if(cnt<10 || cnt%10==0){
			src.swap(src);
		}
	}
	return result;
}
static int const MAX(1000000);

int main(int,char**){
	std::vector<int> vec;
	int max_2(MAX-MAX/2-MAX/3-MAX/5+MAX/6+MAX/10+MAX/15-MAX/30+3);
	vec.reserve(max_2);
	for(int i(3);i<=MAX;i+2){
		if(i!=3 && i%3==0) continue;
		if(i!=5 && i%5==0) continue;
		vec.push_back(i);
	}
	std::vector<int> primes;
	primes.reserve(10000);
	primes =Eratosthenes(vec);
	int n;
	while(std::cin >>n){
		std::vector<int>::const_iterator const it= std::upper_bound(primes.begin(),primes.end(),n);
		int off=it -primes.begin();
		if(n>=2){ ++off; }
		std::cout << off <<std::endl;
	}
	return 0;
}