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 <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;

int main(){
    vector<ll> era(10000000,0);
    for (int i=1; i<era.size(); i++) {
        era[i]=i;
    }
    for (int i=2; i<era.size(); i++) {
        if (era[i]!=0) {
            ll q = i + era[i];
            while (q<era.size()) {
                era[q]=0;
                q += era[i];
            }
        }
    }
    int n;
    while (cin >> n) {
        int ans=-1;
        for (int i=1; i<=n; i++) {
            if (era[i]==i) {
                ans++;
            }
        }
        cout << ans <<endl;
    }
}

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

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,max;
	int count[N_MAX];
	bool so[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		so[i]=true;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	so[0]=so[1]=0;
	for(soi=0,i=2;i<=1000;i++){
		if(so[i]==0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=false;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

C++: #include<cstdio>

long prim[1000100];
long prima[1000100];
    
int main() {
    long n, i, x = 0;
    for (i = 2; i <= 1000000; i++) {
        prim[i] = i;
    }
    for (i = 2; i <= 1000000; i++) {
        if (prim[i] != 0) {
                  prima[x] = prim[i];
                  x+= 1;
                  int j = i;
                  while ( j <= 1000000) {
                        prim[j] = 0;
                        j+= i;
                  }
        }
    }
    while (scanf("%ld", &n) != EOF) {
          long a = 0;
          while ( prima[a] <= n) {
                a++;
          }
          printf("%ld\n", a);
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>

/*??????????????¨?????¢??°       */
/*????????????0????????\????????¨???*/
void print_rist(char *rist, int num){
	int i = 2;
	
	while(i <= num) {
		if (rist[i] != 0) {
			printf("%d ", i);
		}
		i++;
	}
	printf("\n");
}


main(){
	char rist[1000001];
	int i, j;
	int input_num = 0;
	int count;
	int ans;
	
	/*??????????????§????´???°????±???????????????\???*/
	for(j = 0; j < 30; j++) {
		scanf("%d", &input_num);
		if (input_num == EOF) {
			break;
		}
		/*??¢?´¢??????????????????*/
		for (i = 1; i <= input_num; i++) {
			rist[i] = 1;
		}	
		rist[i] = 0;
		rist[1] = 0;
		/*?´???°??????????????????*/
		count = 2;
		while((count * count) <= input_num) {	/*???input_num??????????????§*/
			i = 2;
			/*count??\??????count????????°??????????????¨???*/
			while((i * count) <= input_num) {
				rist[i * count] = 0;
				i++;
			}
			count++;
			/*?¬????count?????????*/
			while(rist[count] != 1) {
				count++;
			}
			
		}
		
		ans = 0;
		for (i = 1; i <= input_num; i++) {
			if (rist[i] == 1) {
				ans++;
			}
		}
		printf("%d\n", ans);
		//print_rist(rist, input_num);
	}
	return 0;
}

C++: #include <stdio.h>

int main(void) {

  int n;
  int num;
  int i,flag,count;

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

    count=0;

    for(num=1;num<=n;num++) {

      flag=1;

      for(i=2;i<num;i++) {
	if(num%i==0) {
	  flag=0;
	  break;
	}
      }
      
      if(num==1) flag=0;

      if(flag==1) { 
	count++;
      }
    }

    printf("%d\n",count);

  }

  return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

bool dp[10000100];

int main()
{
	int N;
	while (cin >> N){
		long ans(0);
		dp[0] = dp[1] = true;
		for (int i = 2; i <= N*N; ++i){
			if (!dp[i]){
				for (int j = 2*i; j <= N; j += i)
					dp[j] = true;
			}
		}
		for (int i = 2; i <= N; ++i){
			ans += !dp[i];
		}
		cout << ans << endl;
	}
}

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

int main(){
	int num, cou, i, j, flag;
	
	while(cin >>num){
		cou = 0;
		for(i = 3; i < num; i+= 2, flag = 0){
			for(j = 3; j < sqrt(num); j += 2){
				if(i % j == 0){
					flag = 1;
					break;
				}
			}
			if(flag == 0) cou++;
		}
		cout <<cou + 2<<endl;
	}
	
	return 0;
}

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

int main(){
	int m=0,n;
	cin>>n;
    for(int i=1;i<=n;i++){
    	int s=0;
    	if(i==1)s=1;
    	if(i>3){
    		for(int j=2;j<=sqrt(i);j++){
    			if(i%j==0)s=1;
    		}
    	}
    	if(s==0)m++;
    }
	cout<<m<<endl;
	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>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	int tmp;
	while (cin >> tmp)
	{
		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;

		prime.clear();
	}

	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

const int MAX = 1000000;
int N;

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);

    vector<bool> is_prime(MAX,true);
    vector<int> prime(MAX,0);
    is_prime[0] = is_prime[1] = false;
    prime[0] = prime[1] = 0;
    int p = 0;
    for(int i = 2; i < MAX; ++i){
        if(is_prime[i]){
            for(int j = i*2; j < MAX; j += i) is_prime[j] = false;
        }
    }

    for(int i = 1; i < MAX; ++i){
        prime[i] = prime[i-1] + is_prime[i];
    }

    while(cin >> N){
        cout << prime[N] << '\n';
    }
    return 0;
}

C++: #include <stdio.h>

int primes[78498], primepis[1000000], num_primes;
int calculated;
int mysqrt(unsigned int x) {
	int a = 0, c = 0, y = 0, i = 0, t = x;
	while (t >>= 1) {
		++i;
	}
	for (i += i & 1; i >= 0; i -= 2) {
		c = (y << 1 | 1) <= x >> i;
		a = a << 1 | c;
		y = y << 1 | c;
		x -= c * y << i;
		/* if(c){
		  x -= y << i;
		} */
		y += c;
	}
	return a;
}
int main() {
	primes[0] = 2;
	primepis[2] = 1;
	calculated = 2;
	num_primes = 1;
	for (unsigned int i = 3; i <= 999999; i += 2) {
		bool is_prime = true;
		int max = (int)(mysqrt(i)) + 1;
		for (int j=1; primes[j] < max && j<num_primes; j++) {
			if (i%primes[j] == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			primes[num_primes++] = i;
			primepis[i] = primepis[i + 1] = primepis[i - 1] + 1;
		}
		else {
			primepis[i] = primepis[i + 1] = primepis[i - 1];
		}
	}
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		printf("%d\n", primepis[n]);
	}
}