Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

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

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

int main() {
  int n;
  bool a[1000000];

  for(int i = 1; i < 1000000; ++i) {
	if(isPrime(i)) {
	  a[i] = true;
	}
  }
  /*
  for(int i = 1; i < 10000; ++i) {
	if(isPrime(i)) {
	  cout << i << " ";
	}
  }
  */
  while(cin >> n) {
	cout << accumulate(&a[1], &a[n + 1], 0) << endl;
  }
  return 0;
}

/*-- primitive algorithm --*/
/*
bool isPrime(int n) {
  for(int i = 2; i < n; ++i) {
	if(n % i == 0) return false;
  }
  return true;
}
*/

C++: #include <stdio.h>
#include<string>
#include<string.h>
#include <math.h>
#include<iostream>
#include <algorithm>
#include <map>
#include <vector>
#include <queue>
using namespace  std;


/*
//my header
#include "define.h"
#include "geometry.h"*/

#define MyAbs(a) ((a)>0?(a):-(a))
#define MyEqualDoule(a,b) (MyAbs(a-b)<1e-6)

#define foreach(i,n) for(i=0;i<n;++i)
#define foreachd(i,n) for(int i=0;i<n;++i)
#define printfInt1(n) printf("%d\n",n)
#define scanfInt1(n) scanf("%d",&n)
#define scanfInt2(a,b) scanf("%d%d", &a, &b)
#define scanfInt3(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define scanfFloat2(a,b) scanf("%f%f", &a,&b)


void init()
{
#ifdef _WIN32
	freopen("1.txt", "r", stdin);
#endif
}

void func();

int main()
{
	init();
	func();

	return 0;
}

class CNumberTheory
{
public:
	//譛?、ァ蜈ャ郤ヲ謨ー
	static int gcd(int a, int b)
	{
		int t;
		while (b) {
			t = a % b;
			a = b;
			b = t;
		}
		return a;
	}
	//譛?ー丞?蛟肴焚
	static int lcm(int a,int b)
	{
		return a / gcd(a,b) * b;
	}
	//郤ソ諤ァ逕滓?蟆丈コ守ュ我コ始逧?エ?焚,螯よ棡a譏ッ邏?焚?碁ぅ荵?ns[a] = true
	static void GenePrimeJudge(int n, bool* ans)
	{
		memset(ans, true, sizeof(bool) * (n+1));
		ans[0] = false;
		ans[1] = false;
		int i;
		for(i = 2; i <= n; ++ i)
		{
			if(ans[i])
			{
				int j = 2;
				int k;
				while((k = i * j++) <= n)
					ans[k] = false;
			}
		}
	}
	//郤ソ諤ァ逕滓?蟆丈コ守ュ我コ始逧?エ?焚,螯Ｑrime[size = p]荳ュ蟄俶叛蟆丈コ始逧?エ?焚
	static void GenePrimeList(int n, int *prime, int& p)
	{
		bool* ans = new bool[n+1];
		memset(ans, true, sizeof(bool) * (n+1));
		ans[0] = false;
		ans[1] = false;
		p = 0;
		int i;
		for(i = 2; i <= n; ++ i)
		{
			if(ans[i])
			{
				prime[p++] = i;
				int j = 2;
				int k;
				while((k = i * j++) <= n)
					ans[k] = false;
			}
		}
	}

	//郤ソ諤ァ逕滓?蟆丈コ守ュ我コ始逧?エ?焚,螯よ棡a譏ッ邏?焚?碁ぅ荵?ns[a] = true,蟷カ荳廃rime[size = p]荳ュ蟄俶叛蟆丈コ始逧?エ?焚
	static void GenePrimeJudgeAndList(int n, bool* ans, int *prime, int& p)
	{
		memset(ans, true, sizeof(bool) * (n+1));
		ans[0] = false;
		ans[1] = false;
		p = 0;
		int i;
		for(i = 2; i <= n; ++ i)
		{
			if(ans[i])
			{
				prime[p++] = i;
				int j = 2;
				int k;
				while((k = i * j++) <= n)
					ans[k] = false;
			}
		}
	}
};

class CSearch
{
public:
	//扈吝ョ壻ク?クェ譛牙コ擾シ磯撼髯榊コ擾シ画焚扈Б?梧アゆササ諢丈ク?クェi菴ソ蠕輸[i]遲我コ嗣ey?御ク榊ュ伜惠蛻呵ソ泌屓-1
	static int BinarySearch(int key, int* arr, int n)
	{
		int l = 0, r = n - 1;
		while(l <= r)
		{
			int mid = (r + l)>>1;
			if(arr[mid] == key)
				return mid;
			if(arr[mid] < key)
				l = mid + 1;
			else
				r = mid + 1;
		}
		return -1;
	}

	//扈吝ョ壻ク?クェ譛牙コ擾シ磯撼髯榊コ擾シ画焚扈Б?悟庄蜷ォ譛蛾?螟榊?邏?シ梧アよ怙蟆冗噪i菴ソ蠕輸[i]螟ァ莠嗣ey?御ク榊ュ伜惠蛻呵ソ泌屓-1
	static int BinarySearch_FirstPos_Greater(int key, int* arr, int n)
	{
		int l = 0, r = n - 1;
		while(l < r)
		{
			int mid = (r + l)>>1;
			if(arr[mid] > key)
				r = mid;
			else
				l = mid + 1;
		}
		return arr[r] > key ? r: -1;
	}
};

bool ans[1000000];
int prime[100000];

void func()
{
	int p;
	CNumberTheory::GenePrimeJudgeAndList(999999, ans, prime, p);

	int n;
	while(~scanf("%d", &n))
	{
		int ret;;
		ret = CSearch::BinarySearch_FirstPos_Greater(n,prime,p);
		if(ret == -1)
			ret = p;
		printfInt1(ret);
	}
}

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

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

C++: #include<stdio.h>
#define N 100010

int main() {
	int ipt;
	int root;
	int cnt = 0;
	int A[N];
	for (int i = 1; i <= N; i++) {
		A[i] = i;
	}
	for (int pos = 2; pos <= N; pos++) {
		root = A[pos];
		if (!root)continue;
		for (int k = 2; k*root <= N; k++) {
			A[k*root] = 0;
		}
	}

	while(1) {
		scanf("%d", &ipt);
		for (int i = 2; i <= ipt; i++) {
			if (A[i] != 0)cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#define INF 999999
using namespace std;

int main()
{
	int n;
	
	while (cin >> n)
	{
		int ans = 0,rootn;

		bool a[INF] ;
		a[0] = false; a[1] = false;

		rootn = sqrt(n)+1;
	
		for (int i = 2; i <= rootn; i++)
		{
			if (a[i]==true)
			{
				for (int j = i+1; j < INF; j++)
				{
					if (a[j] == true && j%i == 0)a[j] = false;
				}
			}
		}
		for (int i = 0; i <= n; i++)
		{
			if (a[i]==true)++ans;
		}
		cout << ans << endl;
	}
			
	return 0;
}

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

using namespace std;

int main() {

	int n;
	int *k;
	
	while (cin >> n) {
		int counter = 0;
		k = (int *)malloc(sizeof(int) * n);
		if (k == NULL) {
			exit(0);
		}
		k[0] = 1;
		for (int i = 1; i < n; i++) {
			k[i] = 0;
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				/*for (int j = 1; j < i; j++) {
					if (k[j] == 0) {
						if ((i+1) % (j+1) == 0) {
							k[i] = 1;
							break;
						}
					}
				}*/
				if (k[i] == 0) {
					for (int t = 2; t <= n/(i+1); t++) {
						k[(i+1)*t-1] = 1;
					}
				}
			}
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				counter++;
			}
		}

		cout << counter << endl;

		free(k);
	}

	return 0;
}

C++: /* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */

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

void wakwaw(int *x) { 
     x[1] = 0; 
     x[2] = 1; 
     for (int i = 3; i <= 1000000; i += 2) 
         x[i] = 1; 
 
 
     for (int i = 3; i <= 1000; i += 2) { 
         if (x[i] == 0) 
             continue; 
         for (int j = 2; i * j <= 1000000; j++) 
            x[i * j] = 0; 
     } 
 
 
     for (int i = 3; i <= 1000000; i++) 
         x[i] += x[i-1]; 
 } 
 
 
 int main() { 
 
 
     int *arr = new int[1000001]; 
     wakwaw(arr); 
 
 
     int n; 
     while (cin >> n) { 
         cout << arr[n] << endl; 
     } 
 
 
     return 0; 
 }

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi prime_count;
void sieve(int max){
    int count = 0;
    vector<bool> table(max + 1, true);
    table[0] = false;
    prime_count.push_back(0);
    table[1] = false;
    prime_count.push_back(0);
    for(int i = 2; i <= max; i++){
        if(table[i]){
            count++;
            for(int j = 2; i * j <= max; j++){
                table[i * j] = false;
            }
        }
        prime_count.push_back(count);
    }
}

int main(){
    int n;
    sieve(10000);
    while(cin>>n){
        cout << prime_count[n] << endl;
    }
}