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 <bits/stdc++.h>
using namespace std;

#define N 1000001

int main() {

	vector<bool> check(N, false);
	vector<long long> prime;
	
	
	for(long long i = 2; i < N; ++i){
		if(!check[i]) prime.push_back(i);
		for(long long j = 2; i * j < N; ++j){
			check[i * j] = true;
		}
	}
	
	int n;
	
	while(cin >> n){
		auto it = lower_bound(prime.begin(), prime.end() , n+1);
		
		cout << distance(prime.begin(), it) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	while (cin)
	{
		string tmpstr;
		int tmp;

		getline(cin, tmpstr);

		tmp = atoi(tmpstr.c_str());

		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;

		//if (cin.eof()) { break; }
	}

	return 0;
}

C++: #include<iostream>
 
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<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int prime[n+1];
        for(int i=0;i<=n;i++)
            prime[i]=1;
            prime[0]=0;
            prime[1]=0;
        for(int i=2;i*i<=n;i++)
             if(prime[i]==1)
        {
            for(int j=2;j*i<=n;j++)
            prime[i*j]=0;
        }
        int c=0;
        for(int i=0;i<=n;i++)
        {
            if(prime[i]==1)
                c++;
        }
        printf("%d\n",c);
    }

}

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

long long int a[1000000];

int main(){

  long long int n;

  for(long long int i=2;i*i<1000000;i++){
    if(a[i]==0){
      for(long long int j=i+i;j<1000000;j+=i) a[j]=1;
    }
  }

  while(cin >> n){

    long long int count=0;

    for(long long int i=2;i<n;i++){
      if(a[i]==0) count++;
    }

    cout << count << endl;

  }
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    int c[max];
    int so=0;
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        if(b[i]!=0){
            for(int j=2; j<=max; j++){
                if(i*j<=max){
                    b[i*j]=0;
                }else{
                    j=max;
                }
            }
        }
    }
    
    for(int i=0; i<=max; i++){
        if(b[i]!=0){
            c[so]=i;
            so++;
        }
    }
    
    

    for(int i=0; i<num; i++){
        for(int j=0; j<so; j++){
            if(c[j]<=a[i][0]){
                a[i][1]++;
            }else{
                j=so;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt;

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

int IsPrime(int n){
    int i;
    for (i=2; i*i<=n; i++){
        if (n%i==0) return 0;
    }
    return 1;
}

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

using namespace std;

int Count(bool [], int, int);

int main() {
  const int N = 1000000;
  bool num[N];
  for (int i = 0; i < N; i++)
    num[i] = true;

  const int N_MAX = 999999;
  const double MAX = sqrt(N_MAX);
  for (int i = 2; i <= MAX; i++) {
    if (num[i]) {
      for (int j = i; i*j <= N_MAX; j++) {
        num[i * j] = false;
      }
    }
  }

  int data;
  while (cin >> data) {
    cout << Count(num, 2, data) << endl;
  }
}

int Count(bool data[], int begin, int end) {
  int count = 0;
  for(int i = begin; i <= end; i++)
    if (data[i])
      count++;

  return count;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
bool IsPrime(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;
  int sum[1000000];
  sum[0]=0;
  sum[1]=0;
  sum[2]=1;
  for(int i=3;i<1000000;i++) {
    sum[i]=sum[i-1];
    if(IsPrime(i)) 
      sum[i]++;
 }
  while(cin>>n)
    cout<<sum[n]<<endl;
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
bool prime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
    int n,c,i;
    while(scanf("%d",&n)!=EOF)
    {
        c=0;
        for(i=2;i<=n;i++)
        {
            if(prime(i))
                c++;
        }
        cout<<c<<endl;
    }
    return 0;
}

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

using namespace std;

int n,np[1000000];
bool isp[1000000];

int main()
{
    memset(isp,1,sizeof isp);
    isp[0]=isp[1]=0;
    for(int i=2;i<1000;i++)
        if (isp[i]) for(int j=i*i;j<1000000;j+=i) isp[j]=false;
    for(int i=1;i<1000000;i++) np[i]+=np[i-1]+isp[i];
    while (~scanf("%d",&n)) printf("%d\n",np[n]);
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	while (1)
	{
		int tmp;

		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;

		if (cin.eof()) { break; }
	}

	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>

using namespace std;

int main()
{
	int n;
	int len = 1;
	vector<int> prime;
	
	//unsigned long t = time(NULL);
	prime.push_back(2);
	for (int i = 3; i < 1000000; i += 2){
		int j;
		for (j = 0; j < len && prime[j] < i / 2; j++){
			if (i % prime[j] == 0){
				break;
			}
		}
		if (j >= len || prime[j] >= i / 2){
			prime.push_back(i);
			len++;
		}
	}
	//printf("%lu\n", time(NULL) - t);
	while (scanf("%d", &n) != EOF){
		int count;
		
		for (count = 0; prime[count] <= n; count++){//;
			//printf("%d\n", prime[count]);
			;
		}
		printf("%d\n", count);
	}
	
	return 0;
}