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<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define EPS (1e-10)
using namespace std;

typedef unsigned int uint;
typedef long long ll;

#define MAX (1000000)
int main(){
  vector<bool> isP(MAX,true);
  vector<int>  ans(MAX,0);
  int n;
  isP[0] = isP[1] = false;
  for(int i=2; i<MAX; i++)
    if(isP[i]){
      ans[i] = ans[i-1] + 1; 
      for(int j=i+i; j<MAX; j+=i)
	isP[j] = false;
    }else{
      ans[i] = ans[i-1];
    }
  
  while(cin>>n) cout<<ans[n]<<endl;
  return 0;
}

C++: #include<stdio.h>
int main ()
{
    int n,i,m,sum;
    while(1)
    {
        sum=0;
        scanf("%d",&n);
        for(m=2;m<=n;m++)
        {
            for(i=2;i<=m;i++)
            {
                if(m%i==0 && i<m)
                {
                    break;
                }
                if(i==m)
                {
                    sum=sum+1;
                }
            }
        }
        printf("%d\n",sum);
    }
    return 0;
}

C++: #include<iostream>
#include<stack>
using namespace std;
int main() {
	int n, ans = 0, i, count = 0,count2=0;
	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			for (int j = 2; j <= i; j++) {
				if (i % 2 != 0 && i % 3 != 0 && i % 5 !=0 && i%7 != 0) {
					count = 1;
					break;
				}
				if (i > 11) {
					if (i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0) {
						count = 0;
						break;
					}
				}
				if (i%j == 0) {
					count++;
				}
				if (i%j != 0) {
					count2++;
				}
				if (count >= 2 ) {
					break;
				}
			}
			if (count == 1) {
				ans++;
			}
			count = 0;
		}
		cout << ans << endl;
		ans = 0;
	}
	return 0;
}

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

int main(){
    int maxy = 100000;
    int prime[maxy];
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < maxy; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= (int)sqrt(maxy); i++){
        if(prime[i] == 1){
            for(int j=i*2; j <= (int)sqrt(maxy); j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; i <= n; i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    if(num == 2) return true;
    if(num % 2 == 0) return false;
    max = ceil(sqrt(num));

    for(c=3; c < max+1; c+=2)
        if(num % c ==0) return false;
    return true;
}

main()
{
    int ans;
    int buff;
    while(cin >> buff)
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(long s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	//memset(prime, 1, sizeof(prime));
	for (int j = 2; j <= MAX; j++) prime[j] = 1;
	prime[0] = prime[1] = 0;
	for (int i = 2; i*i<= MAX; i++){
		if (prime[i]){
				for (int j = i *i; j <= MAX; j += i){
				prime[j] = 0;
			}
		}
	}
	
	int n, m;
	while (cin >> n>>m){
		if (n==m) cout <<0 << endl;
		else {

		}
	}
	return 0;
}

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

using namespace std;

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

int main(){
	int n;

	while(cin >> n){
		printf("%d\n",HowManyPrimeNumbers2(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){
	int i,j,cnt,root,rt;

	// 3 から n までの奇数の個数 + 1 を n に代入
	cnt = ((int)((((double)(n - 2)) / 2) + 0.5)) + 1;

	// 最大処理数を求める
	root = (int)sqrt((double)n);

	// a
	for(i=3;i<=root;i+=2){
		rt = MySqrt(i);
		for(j=3;j<=rt;j+=2){
			if((i % j) == 0){
				cnt += ((int)(n / i));
				break;
			}
		}
		cnt -= ((int)(n / i));
	}

	return n;
}

int MySqrt(const int i){
/*	int n;

	n = i - 1;

	return (int)(1 + (1 / 2) * (double)(i - 1) - (1 / 8) * (double)(i - 1) * (i - 1) + (1 / 16) * (double)(i - 1) * (i - 1) * (i - 1)); */

	return (int)sqrt((double)i);
}

C++: #include <bits/stdc++.h>
using namespace std;

typedef long long ll;
 
ll mod_pow(ll x, ll n, ll mod){
  ll res = 1;
  while(n > 0){
    if(n & 1) res = res * x % mod;
    x = x*x % mod;
    n >>= 1;
  }
  return res;
}

ll mod_mul(ll x, ll n, ll mod){
  x %= mod;
  n %= mod;
  return x*n % mod;
}

bool millrr_rabin(ll n){
  if(n == 2) return true;
  if((n & 1) == 0 || n <= 1) return false;
  int a[] = {2, 3, 5, 7, 11, 13, 17, -1}, r;
  ll s = 0, d, x;
  d = n - 1;
  while((d & 1) == 0){
    s++;
    d = d >> 1;
  }
  
  for(int i = 0 ; a[i] != -1 && a[i] < n ; i++){
    if((x = mod_pow(a[i], d, n)) != 1){
      for(r = 0 ; r < s ; r++){
	if(x == n-1) break;
	x = mod_mul(x, x, n);
      }
      if(r == s) return false;
    }
  }
  return true;
}

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

int main(){
  
  int n;
  while(cin >> n){
    int ans = 0;
    for(int i = 2 ; i <= n ; i++){
      if(isPrime(i)) ans++;
    }
    cout << ans << endl;
  }
  
  
  return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX 10000000
int prime[MAX];

int main(){
	prime[1]=1;
	prime[2]=0;
	prime[3]=0;

	for(int i = 2;i<=MAX;i++)
		if(prime[i]==0)
			for(int j = 2 * i;j<=MAX;j+=i)
				prime[j]=1;
	
	int n;
	while(true){
	
	cin >> n;
	if(cin.eof())
		break;
		
	int num = 0;	
	for(int k=1;k<=n;k++)
		if(prime[k]==0)
			num++;

	cout << num << endl;
	}
	return 0;
}

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

bool prime[MAX]={};

void run(){
  for(int i=2;i<MAX;i++){
    prime[i]=true;
  } 

  for(int i=2;i<MAX;i++){
    if(!prime[i])continue;
    for(int j=2;j*i<MAX;j++){//i*1 is prime number
      prime[i*j]=false;
    }
  }
}

int main(){

  run();
  
  int n;
  while(cin>>n){
    int sum=0;
    for(int i=2; i<=n; i++){
      if(prime[i])sum++;
    }
    cout<<sum<<endl;
  }

}