Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    long in[30];
    long out[30];
    int n = 0;
    while(cin >> in[n]){
        
        long p[1000];
        //int length = sizeof(p) / sizeof(*p);
        int m = 0;
        //printf("length: %d", length);
        for (int i = 2; i <= in[n]; i++) {
            bool prime = true;
            for(int j = 0; j < m; j++){
                if (i % p[j] == 0) {
                    prime = false;
                }
            }
            if (prime) {
                p[m] = i;
                //printf("%ld\n", p[m]);
                m++;
            }
        }
        
        int s = 0;
        while (in[n] >= p[s]) {
            s++;
        }
        out[n] = s;
        n++;
    }
    
    for (int i = 0; i < n; i++) {
        printf("%ld\n", out[i]);
    }
    
    return 0;
}

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

bool Prime(int n);

int main(){

  int n;
  int sum;

  while(scanf("%d",&n)!=0){
    sum = 0;
    for(int i=3; i<=n; i+=2){
      sum += Prime(i);
    } 
    cout << sum+1 << endl;
  }

  return 0;
}


bool Prime(int n){

  if(n%2==0)
    return false;

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

  return true;
}

C++: #include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void init();
void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
bool non = true;
bool prime = false;

void init()
{
		table[0] = non;
	table[1] = non;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = non;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

}

void func()
{
	
	int n;

	init();

	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);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 PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,100000){
	bool flg = true;
	REP(j,primes.size()) if(i % primes[j] == 0 ) {
	    flg = false;
	    break;
	}
	if(flg) primes.PB(i);
    }

    int n;
    while(true){
	cin >> n;
	if(cin.eof())break;
	int res = upper_bound(ALL(primes),n) - primes.begin();
	cout << res << endl;
    }

    return 0;
}

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



bool primeJudge(int num) {
	if (num == 1)return false;
	if (num == 2)return true;

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

int main() {
	
	int n;
	int count;
	while (cin >> n) {
		count = 0;
		for (int i = 1; i <= n; i++) {
			if (primeJudge(i)) {
				count++;
			}
		}

		printf("%d\n", count);

	}

	//system("pause");
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4??????
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8??????
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

int mm = 999999+1;
vector<bool> d(mm,true);

void hoge(){ FOR(i,2,mm) for(int j = 2; i*j <= mm; j++) d[i*j] = false; }

void solve() {
    vector<int> dp(mm,INF);
    int val;
    int m = 2;
    dp[m] = 1;
    d[0] = d[1] = dp[0] = dp[1] = 0;
    hoge();
    while(cin >> val){
        if(dp[val] == INF){
            FOR(i,m+1,val+1){
                dp[i] = dp[i-1] + (d[i] ? 1 : 0);
            }

            m = val;
        }
        cout << dp[val] << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    solve();

    return 0;
}

C++: #include <stdio.h>
#include<iostream>
#include <math.h>
using namespace std;
int main() {
        int n;
        int data=0;
        while(scanf("%d",&n)!=EOF&&data<=30){
            int a[n];
            int num=0;
            for(int i=0; i<=n; i++) {
                a[i] = i;
            }
            a[1] = 0;
            for (int i=2; i<sqrt(n); i++) {
                for (int j=i+1; j<=n; j++) {
                        if (a[j]!=0 && a[j]%i==0) {
                                a[j] = 0;
                        }
                }
            }
            for(int i=2;i<=n;i++)
                if(a[i]!=0)
                    num++;
            cout<<num<<endl;
            data++;
        }
        return 0;
}

C++: #include<iostream>
#include<cassert>
#include<time.h>
#include<cmath>
using namespace std;

/**
作用：判断一个数是否是素数
参数x：待判断的素
参会primes：存储比x小的所有素数 的数组
返回：是素数返回true，否则返回false
*/
bool isPrime(int x,int *primes)
{
    for(int i=0;primes[i]*primes[i]<=x;++i) //用primes中存储的素数做为试除因子。
    {
        if(x%primes[i]==0) return false;
    }
    return true;
}


/**
作用：统计[2,n]之间的素数的个数
参数：n
返回：素数的个数
*/
int countPrimes(int n) {
    
    if(n<2) return 0;
    
    int count=0;
    int* primes = new int[(n-1)/2+1] ;
    
    if(n >=2) primes[count++] = 2;   //2是第一个素数，直接将他放入数组。

    for(int i=3;i<=n;++i)
    {
        if(isPrime(i,primes))   //如果 i为素数
        {
            primes[count++] = i; //则将 i存储到数组中
        }
    }

    delete[] primes;
    return count;

}

int main()
{
    int n;
    while (cin >> n) {
        int total = countPrimes(n);
        cout << total <<endl;
    }
    
    return 0;
}

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

int sosu( int n ) {
	int i , lim = (int)(sqrt(n));
	
	if ( n == 2 ) return 1;
	if ( n % 2 == 0 ) return 0;
	
	for ( i = 3; i <= lim; i+=2 ) {
		if ( n % i == 0 ) return 0;
	}
	return 1;
}

int main (void) {
	int n , i , count = 0;
	
	while ( scanf("%d",&n) != EOF ) {
		for ( i = 2; i <= n; i++ ) {
			if ( sosu(i) ) count++;
		}
		printf("%d\n",count);
	}
	return 0;
}