Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

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

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

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

using namespace std;

bool a[1000000];

int main()
{
    memset(a, true, sizeof(a));

    int n;
    while (~scanf("%d", &n)) {
        for (int i = 2; i * i <= n; ++i) {
            if (!a[i]) continue;
            for (int j = i + i; j <= n; j += i) a[j] = false;
        }
        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += a[i];
        printf("%d\n", cnt);
    }
}

C++: #include <stdio.h>

int main(int argc, const char * argv[])
{
    int i, j, k, n, count;
    int a[999999];
    
    count = 0;
    
    while(scanf("%d",&n) != EOF){
        if (count == 0) {
            if (n > 1) {
                a[count++] = 2;
                if (n > 2) {
                    a[count++] = 3;
                    for(i=5; i<=n; i+=2){
                        k=0;
                        for(j=0; a[j]*a[j] <= i; j++){
                            if(i%a[j] == 0) {
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0) {
                            a[count++] = i;
                        }
                    }
                }
            }
            printf("%d\n",count);
        } else {
            if (n <= a[count - 1]) {
                for (i=count - 1; n < a[i]; i--);
                printf("%d\n", i+1);
            } else {
                if (a[count-1] == 2) {
                    a[count++] = 3;
                    printf("%d\n",count);
                } else {
                    for(i=a[count - 1]+2; i<=n; i+=2){
                        k=0;
                        for(j=0; a[j]*a[j] <= i; j++){
                            if(i%a[j] == 0) {
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0) {
                            a[count++] = i;
                        }
                    }
                    printf("%d\n", count);
                }
            }
        }
    }
    return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
  int n,flag=1,sum = 0;

  while(cin >> n){

    for(int i=2; i <= n; i++){
      if(i != 2 && i%2 == 0) flag = 0;
      else{
	for(int j=3; j < i/2; j++){
	  if(i%j == 0 ) flag = 0;
	}
      }
      if(flag == 1) sum++;
      flag = 1;
    }
    cout << sum <<endl;
    sum = 0;
  }
}

C++: #include <stdio.h>
int main(){
    int mem[ 50000 ] = { 2,3,5,7,11 };
    int i,m = 5,x;
    for( i = 12;i < 100000;i++ ){
        if( i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0 && i % 11 != 0 ) mem[ m++ ] = i;
    }
    while( 1 ){
        if( feof( stdin ) != 0 ) break;
        scanf( "%d",&x );
        for( i = 0;mem[i] <= x;i++ );
        printf( "%d\n",i );
    }
    return 0;
}

C++: #include<cstdio>
#include<iostream>
using namespace std;
int prime[1000000];
int main(){
    int n,ans=0;
    for(int i=0;i<1000000;i++)
        prime[i]=1;
    prime[1]=0;
    prime[2]=1;
    for(int i=1;i<1001;i++){
        if(prime[i]==1){
            for(int j=i+1;j<1000000;j++){
                if(j%i==0)
                    prime[j]=0;
            }
        }
    }
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        if(prime[i]==1)
        ans++;
    }
    printf("%d\n",ans);
    return 0;
}

C++: #include <cstdio>

int Eratos[1000000];

int main()
{
	Eratos[0] = Eratos[1] = 0;
	for (int i = 0; i < 1000000; i++){
		Eratos[i] = 1;
	}
	for (int i = 2; i < 1000; i++) {
		if (Eratos[i]) {
			for (int j = 2 * i; j < 1000000; j += i) {
				Eratos[j] = 0;
			}
		}
	}
	int n,res;
	res = 1;
	for (int i = 2; i < 1000000; i++) {
		if (Eratos[i])
			Eratos[i] = res;
		res++;
	}
	while (scanf("%d", &n)) {
		res = 0;
		while (!Eratos[n]) {
			n--;
		}
		printf("%d\n",Eratos[n]);
	}
	return 0;
}

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

inline bool prime(int n) {
	for(int i=2;i<=sqrt(n);++i) {
		if(n%i==0) { return false; }
	}
	return true;
}

int main() {
	int n;
	while(scanf("%d",&n) != EOF) {
		int cnt=0;
		for(int i=2;i<=n;++i) {
			if(prime(i)) { ++cnt; } 
		}
		printf("%d\n",cnt);
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

#define M 10000000
bool prime[M];
int main()
{
	
	int ans, n;

	for (int i = 2; i * i < M; i++){
		if (prime[i] == false){
			for (int j = i; j < M; j += i){
				if (!(i == j)) {
					prime[j] = true;
				}
			}
		}
	}
	while (cin >> n){
	  ans = 0;
		for (int i = 2; i <= n; i++){
	 	 if (prime[i] == false) ans++;
	  }
		cout << ans << endl;
	}
	return (0);
}

C++: #include <stdio.h>

int main(void){
int n;
while(scanf("%d",&n)!=EOF){
int count=0;
for(int m=2;m<=n;m++){
bool check=true;
for(int i=2;i<m;i++){
if(i!=m && m%i==0){
check=false;
}
}
if(check==true){
count++;
}
}
}
return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  while(cin >> n){
    int cnt=0,res=0;
    for(int i=2; i<=n; i++){
      for(int j=1; j<=i; j++){
        if(i%j == 0) cnt++;
        if(cnt > 2) break;
      }
      if(cnt==2) res++;
      cnt = 0;
    }
    cout << res << endl;
  }
  return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int a[MAX_V] = {'0'};
int sum[MAX_V+1];
int main() {
  int i, k, v, j, m, n;
  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;
      }
    }
  }
  sum[0] = 0;
  for(m = 0; m < MAX_V; m++) {
    sum[m+1] = sum[m] + prime[m];
  }
  while( scanf( "%d", &n ) != EOF ) {
    for( j = 2; j <= n; j++ ) {
      int isprime = prime[j];
      int isprimee = prime[j-2];
    }
    printf( "%d\n", sum[n+1] );
  }
  return 0;
}

C++: #include<cstdio>
#include<string.h>
using namespace std;
int pNum;
bool IsPrime[1000000];
int Prime[1000000];
void GetPrime(){
    memset(IsPrime,true,sizeof(IsPrime));
    IsPrime[0]=IsPrime[1]=false;
    pNum=0;
    for(int i=2;i<1000000;i++){
        if(IsPrime[i])Prime[++pNum]=i;
        for(int j=1;j<=pNum&&Prime[j]*i<1000000;j++){
            IsPrime[Prime[j]*i]=false;
            if(i%Prime[j]==0)break;
        }
    }
}
int main(){
    GetPrime();
    int n;
    while(scanf("%d",&n)){
        int count=0;
        for(int i=1;i<=pNum;i++){
            if(Prime[i]<n)count++;
            if(Prime[i]==n){
                count++;break;
            }
            if(Prime[i]>n)break;
        }
        printf("%d\n",count);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#define maxn 1000000
using namespace std;
int prime[maxn],number[maxn];
void getprime()
{
    int m=sqrt(maxn+0.5);
    for(int i=2;i<=m;i++)
    {
        if(!prime[i])
        {
            for(int j=i+i;j<maxn;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    int sum = 0;
    for(int i=2;i<maxn;i++)
    {
        if(!prime[i])
        {
            sum++;
        }
        number[i]=sum;
    }
}
int main ()
{
    int n;
    getprime();
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",number[n]);
    }
}
/**
--------------------- 
???zhaiqiming2010 
???CSDN 
???https://blog.csdn.net/zhaiqiming2010/article/details/62281598 
?????????????????????????
**/