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>

using namespace std;

int MAX = 1000000;
int c[1000010];

int main() {
	int n;
	
	for (int i=0; i<=MAX; i++) c[i] = 1;
	
	for (int j=2; 2*j<=MAX; j++) c[2*j] = 0;
	
	for (int i=3; i<=MAX/2; i++) {
		if (c[i]==0) continue;
		for (int j=2; i*j<=MAX; j++) {
			c[i*j] = 0;
		}
	}
		
	while (cin>>n) {
		
		int ans = 0;
		for (int i=2; i<=n; i++) {
			ans += c[i];
		}
		cout << ans << endl;
	}
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
  int n,prime[1000000];

  for(int i=0;i<1000000;i++)prime[i]=0;
  prime[0]=prime[1]=1;

  cin >> n;

  for(int i=2;i*i<=n;i++)
    if(prime[i]==0)
      for(int j=2*i;j<=n;j+=i)
	prime[j]=1;
  
  int cnt=0;
  for(int i=0;i<=n;i++)
    if(prime[i]==0)cnt++;

  cout << cnt << endl;

  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#define F first
#define S second
using namespace std;
typedef pair<int, int> P;
const int INF = 1 << 30, Array = int(1e6);

int main(){

  int n, i, j, maxin = 2;
  bool jud;
  vector <int> vec;

  while(cin >> n){
    if(maxin <= n){
      for(i = maxin;i <= n; i++){
        jud = 0;
        for(j = 0;  j < vec.size() ; j++){
          if(vec[ j ] * vec[ j ] > i) break;
          if( !( i % vec[ j ] ) ){
            jud = 1;
            break;
          }
        }
        if(!jud)
          vec.push_back( i );
      }
      maxin = n;
    }
    cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin()   <<endl;
  }
}

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

int main()
{
	int n;
	vector<int> prime;

	while (cin >> n) {
		prime.push_back(2);

		for (int I = 2; I <= n; I++) {
			bool isPrime = true;
			for (int i = 0; i < prime.size(); i++) {
				if (I%prime[i] == 0)
					isPrime = false;
			}
			if (isPrime)
				prime.push_back(I);
		}
		cout << prime.size() << endl;
		prime.clear();
	}
	return 0;
}

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

int main(){
	int n,s,ans;
	while(cin >> n){
		ans=0;
		for(int j=2;j<=n;j++){
			s=0;
			for(int i=2;i<=sqrt(j);i++){
				if(j%i==0){
					s++;
				}
			}
			if(s==0){
				ans++;
			}
		}
		cout << ans << "\n";
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int n,k,kk;
	while(cin>>n){
		kk=0;
        if(n==1)cout<<"0"<<endl;
        else if(n==2)cout<<"1"<<endl;
        else {
          for(int j=3;j<=n;j+=2){
			k=0;
			for(int i=3;i<=j;i+=2){
				if(j%i==0)k++;
		        }
		     if(k==1)kk++;
		   }
             }
       cout<<kk+1<<endl;
	   }
	return 0;
	}

C++: #include <stdio.h>
#define MAX 10^6

int main(void)
{
	int n,ans,i,k,j=0;
	int ansbox[MAX];

	for(i=2 ; i<MAX ; i++){
		for(k=2 ; k<=i ; k++){
			if(i%k==0)
				break;
		}
		if(i==k){
			ansbox[j]=k;
			j++;
		}
	}

	while(scanf("%d",&n) != EOF){
		for(i=2 ; i<=n ; i++){
			if(ansbox[i]<=n)
				ans++;
		}
		printf("%d",ans);
		ans=0;
	}
	
	return 0;
}

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

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[j]=false;
			}
		}
	}

	int n_prime[1000000];

	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>
#include <vector>
#define N 1000000
using namespace std;

int main(void){
	int n;
	int i,j;
	int count;
	vector<int> prime(N);

	for(i=0;i<N;i++){
		if(i%2==0||i==1) prime.at(i)=0;
		else prime.at(i)=1;
	}
	prime.at(2)=1;
	for(i=3;i<(N/2);i+=2){
		if(prime.at(i)==1){
			for(j=2;i*j<N;j++){
				prime.at(i*j)=0;
			}
		}
	}
	while(cin >> n){
		count=0;
		for(i=2;i<=n;i++){
			if(prime.at(i)==1) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

#define int long long
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int f[1000000];

signed main(){
    fill_n(f,1000000,1);
    f[0]=f[1]=0;
    for(int i=2;i<1000000;i++){
        if(!f[i])continue;
        for(int j=i+i;j<1000000;j+=i)f[j]=0;
    }
    for(int i=1;i<1000000;i++)f[i]+=f[i-1];

    int n;
    while(cin>>n)cout<<f[n]<<endl;
    return 0;
}

C++: #include<cstdio>
#include<cstring>
using namespace std;
bool isPrime(int n)
{
    for(int i = 2; i * i <= n; i ++)
    {
        if(n % i == 0)
        {
            return false;
        }
    }
    return true;
}
int main()
{
    int n;
    while(scanf("%d", &n) != EOF)
    {
        int res = 0;
        for(int i = 2; i <= n; i ++)
        {
            if(isPrime(i))
            {
                res ++;
            }
        }
        printf("%d\n",res);
    }
    return 0;
}

C++: import java.io.*;

import java.util.*;
import java.math.*;



class Main{

	private static ArrayList<Integer> sum_check(int a){

		int count = 0;
		ArrayList<Integer> s = new ArrayList<Integer>();
		
		for(int i=0;i<=a;i++){
			s.add(0);
		}
		s.set(2,1);
		for(int i=3;i<=a;i=i+2) s.set(i,1);
		for(int i=3;i<=Math.sqrt(a);i=i+2){
			if(s.get(i) == 0) continue;
			for(int j=i+i;j<=a;j=j+i)s.set(j,0);
		}		
		return s;

	}

	

		public static void main(String args[]) throws IOException{

			Scanner scan = new Scanner(System.in);

			int n,count;
			ArrayList<Integer> a = new ArrayList<Integer>();

			ArrayList<Integer> res = new ArrayList<Integer>();


			while(scan.hasNext()){
				count = 1;

				String str1 = scan.next();

				n = Integer.valueOf(str1).intValue();

				if(n != 1){
				a = sum_check(n);
				for(int i=3;i<=n;i=i+2){
					if(a.get(i) == 1)count++;
				}
				res.add(count);
				}
				else res.add(0);

			}
			for(int i=0;i<res.size();i++){
				System.out.println(res.get(i));
			}

		}

}

C++: #include<iostream>
#include<stdio.h>
#define M 1000000
using namespace std;
int a[M]={0};
int main()
{
    int n,i,j,k=0,l;

    a[0]=1;
    a[1]=1;
    for(i=2;i<=M;i++){
        for(j=2;i*j<M && a[i]!=1;j++){
            a[i*j]=1;
        }
    }
    while(cin>>n)
    {
        k=0;


    for(i=1;i<=n;i++){
        if(a[i]==0)k++;
    }
    cout<<k<<endl;
    //k=0;
    }



    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <string.h>

int prime(int n) {
  int k;
  for(k = 2; k * k <= n; k++) {
    if(n % k == 0) return 0;
  }
  return 1;
}

int cntPrime(int n) {
  int cnt = 0, i, k;
  for(i = 2; i <= n; i++) {
    cnt += prime(i);
  }
  return cnt;
}

int main() {
  int a;
  int arg[1024] = { 0 };
  int cnt = 0;
  while(scanf("%d", &a) != EOF) {
    printf("%d\n", cntPrime(a));
  }
  int i;
  for(i = 0; i < cnt; i++) {
  }
}