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>
#include <algorithm>

#define pb push_back

using namespace std;

const int MAX=100000;
int main(void)
{
	int x;
	bool p[MAX];
	int cnt;
	int i1,i2;

	fill(p,p+MAX,false);

	for(i1=2;i1<MAX;i1++){
		for(i2=2;i2*i2<=i1;i2++){
			if(i1%i2==0) break;
		}
		if(i2*i2>i1) p[i1]=true;
	}

	while(1){
		cin>>x;
		if(cin.eof()) break;

		cnt=0;
		for(i1=0;i1<=x;i1++){
			if(p[i1]) cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
int main(void)
{
    int n;
    while (cin >> n)
    {
        int c = 0;
        for (int i = 2; i <= n; i++)
        {
            int t = 1;
            for (int j = 2; j < i; j++)
            {
                if (i % j == 0)
                {
                    t++;
                }
            }
            if (t == 1)
            {
                c++;
            }
        }
        cout << c << endl;
    }
}

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

int main() {
    long in, out;
    int p, count;
    
    do{
         cin >> in;
         out = 0; 
         
         for(int i = 1; i <= in; i++)
         {
                 count = 0;
                 for(p = 1; p <= i; p++)
                 {
                       if(i % p == 0){
                            count++;
                            }
                 }
                 
                 if(count == 2){
                          out++;
                 }
         }
         
         cout << out << endl;
         
    }while(in);  
    

    return 0;
}

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

using namespace std;

#define MAX_N 99999
#define MAX_D 30

bool prime_check(int n, int k = 2)
{
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return prime_check(n, k + 1);
}

int main()
{
	int n;

	bool isprime[MAX_N + 1];

	for (int i = 2; i < MAX_N + 1; i++)
	{
		isprime[i] = prime_check(i);
	}

	while (cin >> n)
	{
		cout << count(isprime + 2, isprime + n + 1, true) << endl;
	}

	return 0;
}

C++: #include<stdio.h>

int main(void){
  int n;
  while(scanf("%d",&n)!=EOF){
    if(n==1){
      printf("%d\n",0);
      break;
    }
    int p[1000000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

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

int main(){
  int prime[100000];
  int isprime[1000000];
  memset(isprime,1,sizeof(isprime));
  isprime[0]=0;
  isprime[1]=0;
  
  for(int i=2;i<1000000;i++){
    if(isprime[i]){
      for(int j=i*2;j<1000000;j+=i){
	isprime[j]=0;
      }
    }
  }
  int pi;
  for(int i;i<1000000;i++){
    if(isprime[i]==1){
      prime[pi]=i;
      pi++;
    }
  }

  int n;
  while(cin>>n){
    int ans;
    while(prime[ans]<=n){
      ans++;
    }
    cout<<ans<<'\n';
  }
  return 0;
}

C++: #include<cstdio>
using namespace std;
const int N = 1000000;

int main(){

  int IsPrime[N];
  IsPrime[0] = -1;
  IsPrime[1] = -1;
  for(int i=2; i*i<=N;i++){
    if(IsPrime[i]==0){
      IsPrime[i] = 1;
      for(int j=2*i; j<=N; j+=i)
        IsPrime[j] = -1;
      }
  }
  int max;
  while(~scanf("%d",&max)){
    int count=0;
    for(int i=1; i<max+1; i++)
      if(IsPrime[i]==1) count++;
    printf("%d\n",count);
  }
}

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

using namespace std;
int sieve[1000005]= {0}, n, i, j, cnt=0;;
int main()
{
    while(cin>>n)
    {
        cnt=0;
        for(i=2; i<=n+2; i++)
        {
            if(!sieve[i])
            {
                for(j=2*i; j<=n+1; j+=i)
                {
                    sieve[j]=1;
                }
            }
        }

        for(i=2; i<=n; i++)
        {
            if(!sieve[i])
            {
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
void eratosthenes(V &v) {
  v[0] = v[1] = false;
  loop(i, 2, v.size()) v[i] = true;
  for (int i = 2; i * i < v.size(); i++) {
    if (v[i]) {
      for (int j = i * 2; j < v.size(); j += i) {
        v[j] = false;
      }
    }
  }
}

void solve() {
  vi v(1000000);
  eratosthenes(v);
  loop(i, 1, v.size()) v[i] += v[i - 1];
  int n;
  while (cin >> n) cout << v[n] << endl;
}

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

int main() {
	int n;
	while(cin >> n && n != EOF) {
		bool* prime = new bool[n+1];
		int count = 0;
		for(int i = 2; i < n; ++i) {
			prime[i] = true;
		}
		prime[0] = prime[1] = false;
		
		for(int i = 0; i < n; ++i) {
			if(prime[i]) {
				count++;
				for(int j = 2 * i; j < n; j += i) {
					prime[j] = false;
				}
			}
		}
		
		cout << count << endl;
		delete[] prime;
	}
}

C++: //0009 Prime Number
//100¢Ì³Ì®nªüÍ³ê½Æ«AnÈºÌfª¢­ç é©oÍ·évOðì¬¹æ
//s²ÆÉêÂÌ®nªüÁÄ¢é@EOFªüÍÌIíèÅ é

#include<iostream>
#include<bitset>
using namespace std;

int main(void)
{
	const int N = 1000000;	//100ÂmÛ
	bitset<N> isPrime;
	int n;
	int i, j;

	while( cin >> n)
	{
		//â¿ðg¢Ü·
		isPrime.set();
		isPrime[0] = isPrime[1] = false;
		for(i = 2; i <= n; i++)
		{
			if(isPrime[i])
			{
				for(j = 2*i; j <= n; j+=i)
				{
					isPrime[j] = false;
				}
			}
		}

		int count = 0;
		for(i = 0; i <= n; i++)
			if(isPrime[i])
				count++;

		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	// Prime Data Set
	char p[1000000] = {0};
	p[1] = 1;
	for( int i=2; i<1000; i++) if(!p[i]) for( int j=i+i; j<1000000; j+=i) p[j] = 1;
	
	int n;
	int sum;
	while( std::cin >> n) {
		sum = 0;
		for( int i=1; i<n; i++) {
			if(!p[i]) sum++;
		}
		std::cout << sum << std::endl;
	}
}