Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V + 1];
int sum[MAX_V + 1];
int main() {
  int i, k, v, n, max = 0;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]){
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &n) != EOF){
    for(i = 2;i <= n;i++){
      sum[n] += prime[i];
    }
  printf("%d\n", sum[n]);
  }
  return 0;
}

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

constexpr int INSUU = 64;
constexpr int SOSUU = 100000;

int Eratosthenes(int* primes){
  primes[0] = 2;
  primes[1] = 3;
  primes[2] = 5;
  primes[3] = 7;
  int prime_p = 4;
  for(int p = 11; p <= SOSUU; p+=2){
    bool is_prime = true;
    for(int i = 0; i < prime_p; i++){
      if((p % primes[i]) == 0){
	is_prime = false;
	break;
      }
    }
    if(is_prime){
      primes[prime_p++] = p;
    }
  }
  return prime_p;
}
int main(){
  int primes[SOSUU];
  int prime_count = Eratosthenes(primes);
  int n;
  while(cin >> n){
    int i = 0;
    for(; i < SOSUU; i++){
      if(n < primes[i]){
	cout << i << endl;
	break;
      }
    }
  }
}

C++:  /*
Write a program which reads an integer n (n &#8804; 999999) and prints the number of prime numbers which are less than or equal to n. A prime number is a natural number which has exactly two distinct natural number divisors: 1 and itself. For example, the first four prime numbers are: 2, 3, 5, 7.
 */

#include <iostream>
#include <algorithm>
#include <math.h>

using namespace std;

 /* 
http://community.appliplanet.co.jp/community/beginner

[|Cg]
+nªfÅÈ¢ÈçÌ½ûªmæè¬³¢àÌÅèØêéÍ¸B
+\ßQÌ{ðO·éB
+ªå«­ÈéÈçÎGXgeXÌâ¿ðÂ©¤©ÀÍbool[]ðg¤B
 */
void solve(int n) {
	bool prime[n+1];
	for (int i=0; i<n+1; i++)
		prime[i] = true;
	prime[0] = false; prime[1] = false;
	int m = (int)sqrt(n);					// nÌ½ûª
	
	for (int i=2; i<=m; i++) {
		if(prime[i]) {
			for (int k=i*i; k<=n; k += i)
				prime[k] = false;
		}
	}
	
	int count = 0;
	for (int i=0; i<n+1; i++) {
		if (prime[i]) count++;
	}
	
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		solve(n);
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (int)(n); i++
using namespace std;
const int MAX_N=int(1e8+5);
vector<bool> is_prime(MAX_N,true);

void sieve(int n) {
	fill(is_prime.begin(),is_prime.end(),true);
		is_prime[0]=false;
		is_prime[1]=false;
		for (int i = 2; i * i <= n; i++) {
			if (is_prime[i]) {
				for (int j = i * i; j <= n; j += i) is_prime[j] = false;
			}
		}
	return;
}
int main() {
	int n;
	while (cin >> n) {
		int cnt = 0;
		sieve(n);
		for (int i = 2; i <= n; i++) {
			if (is_prime[i]) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
}

C++: #include <cstdio>
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	static bool cmp[1000000] = { true };
	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;

#define Max 1000000

int prime [10000000];

int main()
{
	int n, out;

	for (int i = 2; i * i < Max; i++){
		if (prime[i] == 0){
			for (int j = i; j < Max; j += i){
				if (!(j == i)) prime[j] = 1;
			}
		}
	}

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

C++: #include <iostream>
#include <vector>
#include <limits.h>
using namespace std;
int main()
{
	int k, n, s, t, i = 0, j, maxV = INT_MIN, A[30] = {};
	while (cin >> k) {
		A[i++] = k;
		if (maxV < k)
			maxV = k;
	}
	s = maxV + 1;
	vector<long> vP(s, 0);
	int c = 0;
	for (k = 2; k < s; ++k){
		if (vP[k] == 0)
			vP[k] = ++c;
		t = (s - 1) / k;
		for (j = 2; j <= t; ++j)
			vP[j * k] = -1;
	}
	for (j = 0; j < i; ++j){
		k = vP[A[j]];
		if (1 == A[j])
			k = 0;
		else if(-1 == k)
			while (-1 == (k = vP[--A[j]])){}
		cout << k << "\n";
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <functional>

class Mod{
		const int n;
		public:
			Mod(const int _n):n(_n){}
			bool operator()(const int _src)const{
				return ! (_src % n);
			}
	};

const std::vector<int> Eratosthenes(const std::vector<int> src){
	std::vector<int> result,tmp(src);
	while(!tmp.empty()){
		int n(tmp[0]);
		result.push_back(n);
		Mod mod(n);
		std::vector<int>::iterator it= std::remove_if( tmp.begin(), tmp.end(), mod );
		tmp.erase(it,tmp.end());
	}
	return result;
}

int main(int,char**){
	int n;
	while(std::cin >>n){
		std::vector<int> vec;
		vec.reserve(n);
		for(int i(2);i<=n;++i)
			vec.push_back(i);
		std::vector<int> primes= Eratosthenes(vec);
		std::cout << primes.size() <<std::endl;
	}
	return 0;
}

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

int pn[1000002];

int main(){
int n, Count;
cin.tie(0);
while(scanf("%d",&n)!=EOF){
Count=0;
memset(pn,0,sizeof(pn));
pn[0]=pn[1]=1;
for(int i=2;i<=n;i++) if(!pn[i]) for(int j=1;i*j<=n;j++) pn[i*j]=1;
for(int i=2;i<=n;i++) if(!pn[i]) Count++;
cout<<Count<<endl;
}
return 0;
}

C++: #include <bits/stdc++.h>
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = (int)1e9;

#ifndef SIEVE
#define SIEVE
// エラストテネスの篩, o(n)程度
// n以下の素数の数を返す, prime[i]: i番目の素数, is_prime[i]: iが素数であるか
int sieve(int n, int prime[] = nullptr, bool is_prime[] = nullptr){
	bool flag0 = false, flag1 = false;
	if(prime == nullptr){
		flag0 = true; prime = new int[n];
	}
	if(is_prime == nullptr){
		flag1 = true; is_prime = new bool[n + 1];
	}

	int p = 0;
	fill(is_prime, is_prime + n + 1, true);
	is_prime[0] = is_prime[1] = false;

	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime[p++] = i;
			for(int j = 2*i; j <= n; j+=i) is_prime[j] = false;
		}
	}

	if(flag0) delete prime;
	if(flag1) delete is_prime;

	return p;
}
#endif

const int N = (int)1e6;
int prime[N];
bool is_prime[N+1];
int res[N];

int main(void){
    int num = sieve(N, prime, is_prime);

    // for(int i = 0; i < 30; i++) printf("prime[%d] = %d\n", i, prime[i]);
    // for(int i = 1; i < N; i++){
    //     res[i] = res[i-1] + is_prime[i];
    // }

    int n;

    while(scanf("%d", &n) != EOF){
        cout << upper_bound(prime, prime + num, n) -prime << '\n';        
    }

    return 0;
}