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 <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int count = 0;
	/*int m = 2, n = 0, num;

	cin >> num;

	int *data = new int[num + 1];
	int *result = new int[num + 1];

	data[0] = 0;
	data[1] = 0;

	do
	{
		for (i = 2 * m; i < num + 1; i += m)
		{

		}
	}
	while
	{

	}*/
	const int N = 9999999;
	int n;
	std::vector<bool> isPrime(N + 1, true);    // ?´???°????????°?????¨??¨ON???

	while (cin >> n)
	{
		count = 0;
		for (int i = 2; i <= n; ++i) {
			if (isPrime[i])
			{
				count++;

				for (int k = i + i; k <= n; k += i)
					isPrime[k] = false;      // ?´???°????????°????´???°????????°?????¨???OFF???
			}
		}

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






	
}

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

int main(){
	bool b[1000000] = {};
	for(int i = 2; i < 1000000; i++){
		b[i] = true;
	}
	for(int i = 2; i < 1000; i++){
		if(b[i]){
			for(int j = i * i; j < 1000000; j += i){
				b[j] = false;
			}
		}
	}

	int n, count = 0;
	cin >> n;
	for(int i = 0; i <= n; i++){
		if(b[i]){
			count ++;
		}
	}
	cout << count << endl;
	return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int i=0,j=0;
	int n=0;
	int count=0;
	int kioku[200000]={0};
	int flg=0;
	while (scanf("%d",&n)!=EOF)
	{
		count=0;
		if (n>=2)
		{
			kioku[0]=2;
			count++;
		}
		for (i=3;i<=n;i+=2)
		{
			for (j=0;j<count;j++)
			{
				if (i%kioku[j]==0)
				{
					flg=1;
					break;
				}
			}
			if (flg==1)
			{
				flg=0;
			}
			else
			{
				kioku[count]=i;
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[1000];
	int data[1000];
	int count;
	int premaxin=1;


	for(i=0;i<1000;i++){
		c[i]=1;
		data[i]=0;
	}
	c[0]=c[1]=0;

	while(scanf("%d",&n)!=EOF){

		if(premaxin<n){
			for(i=0;i<=n;i++){
				if(c[i]==1){
					if(premaxin>i){
						j=premaxin;
					}else{
						j=i+1;
					}
					for(;j<=n;j++){
						if(j%i==0){
							c[j]=0;
						}
					}
				}
			}

			count=data[premaxin];
			for(i=premaxin+1;i<=n;i++){

				if(c[i]==1){
					count++;
				}
				data[i]=count;
			}
		}

		printf("%d\n",data[n]);
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
	int sosuu[] = { 2, 3, 5 }, i, x, y = 3,n=0,z;
	
	while (scanf("%d", &n)!=EOF){
		z = 0; 
		for (i = 3; i < n + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0)break;
				if (x + 1 == y){ sosuu[y] = i, y++;}
			}
		}
		for (i = 0; i < y; i++){ if (sosuu[i] > n)break; z++; }
		printf("%d\n", z);
	}
	return 0;
}

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


int main(){
	int number,cnt=0;
	cin>>number;
	int* arr = new int[number+1];
	for (int i = 1; i <= number; i+=2)
	{
		arr[i-1]=0;
		arr[i]=1;
	}
	for (int i = 3; i < sqrt(number); i+=2)
		if (arr[i])
			for (int j = i+i; j <=number; j+=i)
				arr[j]=0;
	arr[2]=1;arr[1]=0;
	for (int i = 0; i < number; i++)
		if (arr[i])
			++cnt;
	cout<<cnt;
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
using namespace std;

int main(){
  int n;
  while(cin >> n){
    int ans = 1;
    for(int i = 3; i<=n; i+=2){
      bool isSosu = true;
      for(int j=3; j <= floor(sqrt(i)); j++){
        if(i%j == 0){
          isSosu = false;
          break;
        }
      }
      if(isSosu){
        ans++;
      }
    }
    cout << ans << endl;;
  }
  return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
bool n[1000000]={0};
bool prime(int n){
	for(int i=2;i<=sqrt ((double)n);i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	for(int k=2;k<=999999;k++){
		if(prime(k))n[k]=true;
	}
	int a,sum=0;
	while(cin>>a){
	for(int j=2;j<a;j++){
		if(n[j])sum++;
	}
	cout<<sum<<endl;
	sum=0;
	}
}

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

int main(){

  int n,i,j,ans;


  while(cin >> n){
    ans = 0;

    for(;n > 1 ; n--){
      if(n == 2 ) ans++;
      for(i = 2 ; i <= n/2 ; i++){
	if(n%i == 0){
	  break; 
	}
      }
      if(n%i != 0){
	ans++;
      }
    }
    cout << ans << endl;

  }
  return 0;
}

C++: #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
const int maxn=999999+10;
int n,cnt;
int pre[maxn],prime[maxn];
int bina_search(int l,int r){
	int mid=(l+r)/2;
	if((prime[mid]<n&&prime[mid+1]>n)||prime[mid]==n)
		return mid;
	if(prime[mid]<n)
		bina_search(mid+1,r);
	else
		bina_search(l,mid);
}
int main(){
	memset(pre,0,sizeof(pre));
	memset(prime,0,sizeof(prime));
	int t=1;
	for(int i=2;i<maxn;i++){
		if(!pre[i])
			prime[t++]=i;
		for(int j=1;j<=t&&i*prime[j]<maxn;j++){
			pre[prime[j]*i]=prime[j];
			if(i%prime[j]==0)
					break;
		}
	}
	while(scanf("%d",&n)!=EOF){
		cnt=bina_search(2,n);
		printf("%d\n",cnt);
	}
	return 0;
}

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

using namespace std;

bool judge_Prime_num(const int& num) {
	if (num < 2)
		return false;
	else if (num == 2)
		return true;
	else if (num % 2 == 0)
		return false;

	double sqrtnum = sqrt(num);
	for (int i = 3; i <= sqrtnum; i += 2) {
		if (num%i == 0)
			return false;
	}
	return true;
}

int main() {
	int n;
	while (cin >> n) {
		int tmp = n;
		int cnt = 0;
		while (tmp > 1) {
			if (tmp != 2 && tmp % 2 == 0) {
				--tmp;
				continue;
			}
			if (judge_Prime_num(tmp)) {
				++cnt;
			}
			--tmp;
		}
		cout << cnt << endl;
	}
}

C++: #include <cstdio>
const int N=1000000;
int p[N],pN[N];
main(){p[0]=0;p[1]=0;int i,k,n,c;
for(i=2;i<N;i++)p[i]=1;for(i=2;i*i<N;){for(k=2;i*k<N;k++)p[i*k]=0;do{i++;}while(!p[i]);}for(i=0,c=0;i<N;i++){p[i]&&c++;pN[i]=c;}for(;scanf("%d",&n)+1;printf("%d\n",pN[n]));}

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

int main(void){
int unti[100002] = {0};
fill(unti,unti + 100001,0);
for(int n = 2;n < 100001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100001;a++)
{
	if((a * n  ) < 100001 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
}
}

C++: #include<iostream>

using namespace std;

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


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

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

	int cnt = 0;
	for (int i = 0; i<1000000; i++){
		if (prime[i] == 0)cnt++;
		ans[i] = cnt;
	}

	while (cin >> n)
		cout << ans[n] << endl;

	return 0;
}