Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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

int count(int n);

int main(void){
	while (true){
		int n; cin >> n;
		if (!n){
			break;
		}
		cout << count(n) << endl;
	}
	return 0;
}

int count(int n){
	int ct = 0;
	bool *prime = new bool[n];
	//bool prime[999999];
	for (int i = 0; i <= n;i++){
		prime[i] = 0;
	}
	prime[2] = 1;
	for (int i = 3; i <= n; i = i + 2){
		prime[i] = 1;
	}
	for (int i = 3; i <= n; i = i + 2){
		if (prime[i] == 0) continue;
		for (int j = i * 2; j <= n; j = j + i){
			prime[j] = 0;
		}
	}
	for (int i = 3; i <= n; i = i + 2){
		if (prime[i] == 1) ct++;
	}
	ct++; //2を数えていない分
	return ct;
	delete[] prime;
}

C++: /*
 * hujx.cpp
 *
 *  Created on: 2015年5月21日
 *      Author: dell
 */
#include<stdio.h>
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<iomanip>
#include<vector>
#include<time.h>
#include<queue>
#include<stack>
#include<iterator>
#include<math.h>
#include<stdlib.h>
#include<limits.h>
#include<map>
#include<set>
#include<bitset>
//#define ONLINE_JUDGE
#define eps 1e-5
#define INF 0x7fffffff
#define FOR(i,a) for((i)=0;i<(a);(i)++)
#define MEM(a) (memset((a),0,sizeof(a)))
#define sfs(a) scanf("%s",a)
#define sf(a) scanf("%d",&a)
#define sfI(a) scanf("%I64d",&a)
#define pf(a) printf("%d\n",a)
#define pfI(a) printf("%I64d\n",a)
#define pfs(a) printf("%s\n",a)
#define sfd(a,b) scanf("%d%d",&a,&b)
#define sft(a,b,num) scanf("%d%d%d",&a,&b,&num)
#define for1(i,a,b) for(int i=(a);i<b;i++)
#define for2(i,a,b) for(int i=(a);i<=b;i++)
#define for3(i,a,b)for(int i=(b);i>=a;i--)
#define MEM1(a) memset(a,0,sizeof(a))
#define MEM2(a) memset(a,-1,sizeof(a))
#define ll long long
const double PI=acos(-1.0);
template<class T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<class T> T lcm(T a,T b){return a/gcd(a,b)*b;}
template<class T> inline T Min(T a,T b){return a<b?a:b;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}
using namespace std;
//#pragma comment(linker,"/STACK:1024000000,1024000000")
int n,m,c;
#define N 210
#define M 1000100
#define Mod 1000000000
#define p(x,y) make_pair(x,y)
const int MAX_len=550;
int f[M],prime[M];
int vis[M];
int tot;
void get_Prime(){
	memset(f,0,sizeof f);
	tot=0;
	int p = (int)sqrt(M)+1;
	for(int i=2;i<p;i++){
		if(f[i]) continue;
		for(int j=i;i*j<M;j++)
			f[i*j] = 1;
	}
	for(int i=2;i<M;i++){
		f[i] ^= 1;
		f[i] += f[i-1];
	}
}
int main(){
    get_Prime();
    while(sf(n)!=EOF){
    	pf(f[n]);
    }
    return 0;
}

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

using namespace std;

int main() {
  int N = 1000001;
  int primes[N];
  int i, j;
  for (i = 2; i < N; i++) {
    primes[i] = 1;
  }

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

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

  return 0;
}

C++: #include <iostream>

using namespace std;

int sang(long long  n,bool *s,long long  *p,long long &m){
	m = 0;
	for(long i = 2; i<=n;i++){
		s[i] = 2;
	}
	for(long i = 2; i<=n; i++){
		if(s[i]){
			p[m++] = i;
			for(long j = i * i; j<= n ; j += i){
				s[j] = 0;
			}
		}
	}
	return m;
}
int main(){
	bool s[100005];
	long long  n,p[100005],m;

	while(cin>>n){
		sang(n,s,p,m);
		cout<<m<<endl;
	}
	return 0;
}

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

bool ba[m] = { true };
int cp(int x) {
	if (x < 2)return 0;
	if (x == 2)return 1;

	int co = 0;
	for (int i = 0; i < m; i++) {
		ba[i] = { true };
	}
	for (int i = 2; i*i <= x; i++) {
		if (ba[i]) {
			for (int j = i*i; j <= x; j += i) {
				ba[j] = { false };
			}
		}
	}
	for (int i = 2; i <= x; i++) {
		if (ba[i]) {
			++co;
		}
	}
	return co;
}

int main() {
	int x;
	while (cin >> x) {
		cout << cp(x) << endl;
	}
	return 0;
}

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

using namespace std;

bool isPrime(int n)
{

    int i, sqr;

    if(n <= 1){
        return false;
    }
    else if(n == 2){
        return true;
    }
    else{
        sqr = sqrt(n);
        for(i = 2; i <= sqr; i++){
            if(n % i == 0){
                return false;
            }

        }

        return true;
    }
}

int main(void)
{

    int n, count = 0;

    scanf("%d", &n);

    for(int i = 1; i <= n; i++){
        if(isPrime(i)){
            count++;
        }
    }
    printf("%d\n", count);



    return 0;
}

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int n;
    vector<int> prime_sieve(1e6, -1);
    for(int i = 2; i < 1e6; i++){
        if(prime_sieve[i] == -1){
            prime_sieve[i] = 1;
            for(int j = i * 2; j < 1e6; j += i){
                prime_sieve[j] = 0;
            }
        }
    }
    vector<int> cumulative_sum{0, 0};
    for(int i = 2; i < 1e6; i++){
        cumulative_sum.push_back(cumulative_sum.back() + prime_sieve[i]);
    }
    while(cin >> n){
        cout << cumulative_sum[n] << endl;
    }
}