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++: #include <iostream>
#include <vector>
using namespace std;

int main(){
    vector<int> isprime;
    int n;
    while (cin >> n){
	for (int i = 0; i <= n; i++) isprime.push_back(1);
	
	int prime = 0;
	for (int i = 2; i <= n; i++){
	    if (isprime[i]){
		prime++;
		for (int j = 2; i * j <= n; j++) isprime[i*j] = 0;
	    }
	}
	cout << prime << endl;
	isprime.clear();
    }
    return 0;
}

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

bool isPrime(int x){
  if(x == 0 || x == 1) return false;

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

int main(){
  int n;

  while(cin >> n){
    int res = 0;

    for(int i = 2; i <= n; i++){
      if(isPrime(i)){
	res++;
      }
    }

    cout << res << endl;
  }
}

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

bool is_prime(std::vector<int> &primes, int n){
	bool ret = true;
	int max_i = sqrt(n);

	for(int i = 0; i < primes.size(); i++){
		if(primes[i] > max_i){break;}
		if(n % primes[i] == 0){
			ret = false;
			break;
		}
	}
	return ret;
}

int main(int argc, char **argv){
	int n = 0;
	std::vector<int> primes;

	primes.push_back(2);

	while(std::cin >> n){
		int num_primes = 1;
		for(int i = 3; i <= n; i += 2){
			if(is_prime(primes, i)){
				num_primes++;
				if(i > primes.back()){
					primes.push_back(i);
				}
			}
		}

		std::cout << num_primes << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<cstring>
#include<string>
#include<queue>
#include<complex>
#include<numeric>
#include<bitset>
#define INF 1001001001
#define EPS 0.000001

using namespace std;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef pair<int,int> pint;

int memo[1000000];

int main(){
	int i,j;
	for(i=2;i<1000000;i++) memo[i]=1;
	for(i=2;i<1000;i++){
		if(memo[i]==1){
			for(j=i;i*j<1000000;j++) memo[i*j]=0;
		}
	}
	for(i=1;i<1000000;i++) memo[i]+=memo[i-1];
	int n;
	while(cin >> n) cout << memo[n] << endl;
	return 0;
}

C++: #include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;

#define max 1000000

int main(){
	bool is_prime[max] = {};
	for (int i = 2; i < max; ++i) {
		is_prime[i] = 1;
	}
	for (int i = 0; i < max; ++i) {
		if (is_prime[i]) {
			for (int j = i; j < max; j += i) {
				is_prime[j] = 0;
			}
		}
	}
	int num_prime[max] = {};
	for (int i = 1; i < max; ++i) {
		num_prime[i] = num_prime[i-1] + is_prime[i];
	}
	int n;
	while (cin >> n) {
		cout << num_prime[n] << endl;
	}
	return 0;
}

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

int main(void){
  int n;
  bool p[1000000];
  p[0] = p[1] = 0;
  p[2] = 1;
  int ans = 0;
  bool flag;
  for(int i = 0; i < 1000000; i++)
    p[i] = false;
  p[2] = true;
  for(int i = 3; i <= 1000000; i += 2){
    flag = true;
    for(int j = 3; j * j <= i; j += 2){
      if(i % j == 0){
	flag = false;
	break;
      }
    }
    if(flag)
      p[i] = true;
  }
  // cout << "end" << endl;
  while(cin >> n){
    int ans = 0;
    for(int i = 2; i <= n; i++){
      if(p[i])
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

using namespace std;

#define N 100000

int main(){

    bool primes[N];
    int  n; 

    fill(primes, primes + (sizeof primes / sizeof *primes), true);
   
    primes[0] = false;
    primes[1] = false;
    
    for(int i = 2; i < N; ++i){
        if(primes[i]){
            for(int j = i + i; j < N; j += i)primes[j] = false;
        }
    }

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

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

int main()
{
	int N = 0;
	while(cin >> N)
	{
		vector < int > v;
		v.resize(N+1);

		for(int i = 0; i <=N; ++i)
		{
			if(i >= 2)
			{
				v[i] = 1;
			} else {
				v[i] = 0;
			}
		}

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

		int count = 0;
		for(int i = 0; i <= N; ++i)
		{
			if(v[i]==1)
				count++;
		}

		cout << count << endl;

	}

	return 0;
}

C++: #include<cstdio>

using namespace std;

int is_prime(int n){
	int i;
	if(n<=1) return 0;
	if(n==2) return 1;
	if(n%2==0) return 0;

	for(i=3;i * i<=n;i+=2)
		if(n%i==0)
			return 0;
	return 1;
}

int main(void){
	int i;
	int n;
	int count;

	for(;scanf("%d",&n)==1;){

		count=0;
		for(i=2;i<=n;i++)
			if(is_prime(i)) 
				count++;

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

	return 0;
}

C++: //
//  AOJ 0009 Prime Number
//
//  Created by TaoSama on 2015-03-23
//  Copyright (c) 2015 TaoSama. All rights reserved.
//
#include <algorithm>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <set>
#include <vector>
#define CLR(x,y) memset(x, y, sizeof(x))

using namespace std;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;

bool is_prime[N];
int n, cnt, ans[N];

int main() {
#ifdef LOCAL
    freopen("in.txt", "r", stdin);
//	freopen("out.txt","w",stdout);
#endif
    ios_base::sync_with_stdio(0);

    memset(is_prime, true, sizeof is_prime);
    is_prime[1] = false; ans[1] = 0;
    for(int i = 2; i < 1e6; ++i) {
        if(is_prime[i]) {
            ans[i] = ++cnt;
            for(int j = 2 * i; j < 1e6; j += i)
                is_prime[j] = false;
        } else ans[i] = cnt;
    }

    while(cin >> n) {
        if(n <= 0) cout << 0 << endl;
        else	cout << ans[n] << endl;
    }

    return 0;
}

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

int main(){
	int x,i,j,a=1,b;
	while(1){
		try{
		cin >> x;
		if(x < 1) throw 1;
		}catch(int){
			break;
		}
		for(i=2;i<=x;i++){
			for(j=2;j<i;j++){
				if(i%j==0) a=0;
			}
			if(a==1)b++;
			a = 1;
		}
		cout << b << endl;
		b = 0;
	}
}

C++: /*
	http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
	Prime Number
*/

#include <stdio.h>
int main(void)
{
	int n, i, j, p=0;
	while(scanf("%d",n)!=EOF){
		for (i = 1; i <= n; ++i)
		{
			for (j = 2; j < i; ++j)
			{
				if (i % j == 0)
				{
					++p;
					break;
				}

			}
		}
	}

	printf("%d\n", p);
	return 0;
}

C++: #include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

using namespace std;

int a[1000010];

bool p(int n){
int m;
for(int i=2;i<=n;i++){
if(n%i==0){ m=i; break;
	}
}
if(m==n) return true;
else return false;
}

int main(){

int n;
while(1){

cin >> n;

if(cin.fail()) break;

int f=floor(sqrt(1.0*n));

for(int i=2;i<=n;i++) a[i]=1;


for(int i=2;i<=f;i++){
if(a[i]!=0){
if(p(i)){
	for(int j=2*i;j<=n;j+=i)
	a[j]=0;
}
}
}

int x=0;
for(int i=2;i<=n;i++){
	if(a[i]!=0) x++;
}

	cout << x << endl;

}

	return 0;
}