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>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

    while(cin >> n){
      prime = 1;
      for(int i=3; i <= n; i++){
        cnt = 0;
        for(int j=2; j<i; j++){
          if(i%j==0) cnt++;
        }
        if(cnt==0) prime++;
      }
      cout << prime << endl;
    }
    return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

void add(int* primes, int& now,int prime) {
	primes[now] = prime;
	now++;
}

int main() {
	int num;
	int primes[1000]; int now = 0;
	while (cin >> num) {
		add(primes, now, Era(num));
	}
	for (int i = 0; i < now; i++) {
		cout << primes[i] << endl;
	}
	return 0;
}

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


using namespace std;
#define MAX_NUM 999999


int do_count(bool *isPrime, int n);

int main(){
  int n;
  //?´???°???true,
  bool flag = false;
  bool isPrime[MAX_NUM];


  int pivot = 2;
  
  for(int i=0;i<MAX_NUM;i++){
    isPrime[i] = false;
  }
  
  while(cin >> n){
    int cnt=0;
    //cout << n << endl;
    //    sqrt_n = sqrt(n);
    for(int i=2;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????
      for(int j=pivot;j<=sqrt(i);j++){
	if(i%j==0){
	  flag = true;
	  break;
	}
      }
      if(flag){continue;}
      isPrime[i]=true;
      //cout << "last: " << i << endl;
    }
    cnt = do_count(isPrime, n);
    //cout << "cnt: " << cnt << endl;
    cout << cnt << endl;
  }
}

int do_count(bool *isPrime, int n){
  int cnt=0;
  for(int i=0;i<=n;i++){
    if(isPrime[i]==true){
      cnt++;
    }
  }
  return cnt;
}

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

bool sieve[1000000];

int main() {
	int n;

	sieve[0] = true;
	sieve[1] = true;

	while (std::cin >> n) {
		if (n <= 1) {
			std::cout << 0 << std::endl;
			continue;
		}

		for (int i = 2; i*i <= n; ++i) {
			if (!sieve[i]) {
				for (int j = i + i; j <= n; j += i)
					sieve[j] = true;
			}
		}

		std::cout << std::count(sieve, sieve + n + 1, false) << std::endl;
	}
}

C++: j,a['   '],s;main(i){for(;++i<1e6||~scanf("%d",&j)&&printf("%d\n",a[j]);)for(s+=!a[j=i];j<1e6;a[i]=s)a[j+=i]=1;}

C++: #include<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  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 sum = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){sum++;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

C++: #include<iostream>

using namespace std;
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 a;
    while( cin >> a ){
    	
        int count = 0;
        
        for(int i=1;i<a+1;i++)
		if(prime[i] == 1)
		count++;
		
        cout << count << "\n";
    }
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
 
int main(){
int n;
 
 
while(cin >> n){
int count =0;
for(int i=2;i<=n;i++){
        for(int j=2;j<=i;j++){
                if(i%j==0 && j != i)    break;
                if(j==i)        count++;
                
                }
        }
 
cout << count << endl;  
 }
return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count[1000000];
		count[1] = 1;
		if(N<0)	break;
	for(int x=2;x<=1000000;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count[i] = count[i-1]+1;
	}
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

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

int a[1000000];

int main()
{
  int n;
  int count;

  for (int i = 2; i < 1000000; i++){
    a[i] = 1;
  }

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

  while (cin >> n){
    count = 0;
    for (int i = 0; i < 1000000; i++){
      if (a[i] == 1){
        count++;
      }
    }
  }

  cout << count << endl;

  return (1);
}

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

bool is_prime(int n){
  if(n<=1)
    return false;

  for(int i=2; i*i<=n; i++){
    if(n%i==0)
      return false;
  }

  return true;
}

int main(){
  bool is_prime[1000000];

  is_prime[0] = is_prime[1] = false;
  for(int i=2; i<1000000; i++){
    is_prime[i] = true;
  }

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

  int n_prime[100000];

  int cnt = 0;
  for(int i=0; i<1000000; i++){
    if(is_prime[i]){
      cnt++;
    }
    n_prime[i] = cnt;
  }

  while(true){
    int n;
    cin >> n;

    if(cin.eof())
      break;

    cout << n_prime[n] << endl;
  }

  return 0;
}

C++: 
#include<iostream>
#define N 1000000


using namespace std;
void PrimeNum(int n,bool Primeif[]){
  for(int i = 2;i*i < n;i++){
    if(Primeif[i] == true){
      for(int k = 2;k * i <= n;k++){
	Primeif[k*i] = false;
}
    }
  }
}
int main(){
  int n,num;
  bool Primeif[N+1];
  Primeif[1] = false;
  for(int i = 2;i < N;i++){
    Primeif[i] = true;
  }
  PrimeNum(N+1,Primeif);
  
  while(cin >> n){
    num = 0;
    for(int i = 0;i < n;i++){
      if(Primeif[i] == true){
	num = num+1;
      }
    }
     cout << num << endl;
     
   } 
    
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<math.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int n,ans;

int main(){
    int N=1000000;
    int prime[N];
    rep(i,N) prime[i] = 1;
    prime[0] = prime[1] = 0;
    rep(i,N){
        if(prime[i]){
            for(int j = i + i; j < N; j+=i){
                prime[j] = 0;
            }
        }
    }
    while(cin>>n){
        ans=0;
        rep(i,n+1)ans+=prime[i];
        out(ans);
    }
}