Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

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

using namespace std;

int main(){
  int i;
  vector<int> knownprime;
  vector<int> ans;
  bool flag;

  while(cin >> i){
    if(cin.eof()){
      break;
    }
    knownprime.clear();
    for(int d = 2; d <= i; d++){
      flag = true;
      for(int& p : knownprime){
	// ?????§??????????????£??????????´???°??§?????£??????????????¨?????§?????????????????°??°???????´???°??¨??????
	if(d%p == 0){
	  flag = false;
	  break;
	}
      }
      if(flag){
	knownprime.push_back(d);
      }
    }
    ans.push_back(knownprime.size());
  }
  for(int& d : ans){
    cout << d << endl;
  }

}

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

int prime[1000000];
void initTbl(){
	//sieve of Eratosthenes
	// 0 : prime
	// 1 : not prime
	memset(prime, 0, sizeof(prime));
	prime[0] = 1;
	prime[1] = 1;

	int limit = 1000000;
	for(int i=4; i<limit; i+=2){
		prime[i] = 1;
	}

	for(int j=3; j*j<=limit; j+=2){
		for(int k=j; j*k<=limit ;k+=2){
			prime[j*k] = 1;
		}
	}
}

//0009
int main()
{
	int n=10;
	initTbl();

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

		for(; n>0; n--){
			if(!prime[n])
				++cnt;
		}
		cout << cnt << endl;

	}
  return 0;
}

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

int main(){
  static bool cmp[1000000] = {true};
  // cout << cmp[3] << cmp[2] << cmp[5]<<endl;
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
        cmp[i*j]=true;
      }
    }
    npr[i] = npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout << npr[n] << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]) for(int j=i*i; j<1000000; j+=i) num[j] = true;
  }
  int n;
  while(cin >>n){
    int ans = 0;
    for(int i=2; i<=n; i++) if(!num[i]) ans++;
    cout <<ans<<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
        int n;

        while (cin >> n) {
                bool *isPrime = new bool[n + 1];
                isPrime[0] = false;
                isPrime[1] = false;
                for (int i = 2; i < n + 1; i++) {
                        isPrime[i] = true;
                }
                for (int i = 2; i <= (int)sqrt(n); i++) {
                        if (isPrime[i]) {
                                for (int j = 2; j <= n / i; j++) {
                                                isPrime[i * j] = false;
                                }
                        }
                }
                int ans = 0;
                for (int i = 2; i <= n; i++) {
                        if (isPrime[i]) {
                                ans++;
                        }
                }
                cout << ans << endl;
                delete [] isPrime;
        }

        return 0;
}

C++: #include <iostream>
using namespace std;
bool num[500000];
int main()
{
	int n;
	while(cin >> n)
	{
		num[0]=num[1]=true; for(int i=2;i<=n;i++) num[i]=false;
		int ans=0;
		for(int i=2;i<n;i++)
		{
			if(num[i]==false)
			{
				for(int j=i*2;j<=n;j+=i) num[j]=true;
			}
		}
		for(int j=2;j<=n;j++) if(num[j]==false) ans++;
		cout << ans << '\n' ;
	}
}

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

int main()
{
	int n, i, k, j, h;
	bool flag = false;

	for(i=0; i<30; i++)
	{
		cin >> n;
		h = 0;
		for(k = 2; k <= n; k++)
		{
			flag = false;
			for(j = 2; j <= sqrt(k); j++)
			{
				if(k % j == 0)
				{
					flag = true;
					break;
				}
			}
			if(flag == false)
				h++;
		}
		cout << h << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

int main(){
  int n;
  while (std::cin >> n) {
    int count=0;//素数の数
    for(int i=2;i<=n;i++){
      if(i==2){
        count++;
        continue;
      }
      int flag=0;
      for(int j=2;j<=sqrt(i);j++){
        if(i%j==0){
          flag=1;
          break;
        }
      }
      if(flag==0){
        count++;
      }
    }
    std::cout << count << '\n';
  }

}

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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))

using namespace std;

using i32 = int;
using i64 = long long;
using u64 = unsigned long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vu64 = vector<u64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
inline u64 xorshift() { static u64 x = 88172645463325252ull; x = x ^ (x << 7); return x = x ^ (x >> 9); }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { if (x < y) x = y; }
template <typename T> inline void amin(T &x, T y) { if (x > y) x = y; }
template <typename T> inline T power(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
template <typename T, typename S> istream& operator>>(istream &is, pair<T, S> &p) { is >> p.first >> p.second; return is; }
template <typename T, typename S> ostream& operator<<(ostream &os, pair<T, S> &p) { os << p.first << ' ' << p.second; return os; }

void solve() {
  vector<int> elat(1000010, 1);
  elat[0] = elat[1] = 0;
  for (int i = 2; i <= 1000000; i++) {
    if (!elat[i]) continue;
    for (int j = i * 2; j <= 1000000; j += i) {
      elat[j] = 0;
    }
  }
  rep(i, 1000000) elat[i + 1] += elat[i];

  int n;
  while (cin >> n) {
    cout << elat[n] << '\n';
  }
}