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 <iostream>
#include <vector>
using namespace std;

int main()
{
        long long max;
        vector<int> pn;
        bool npn[1000000];
        npn[0] = npn[1] = true;


        while(cin >> max){
                for(long i=2;i<max;i++){
                        if(npn[i]) continue;
                        pn.push_back(i);
                        for(long j=i*1;j<=max;j+=i)npn[j] = true;
                }

                cout << pn.size() << "\n";
                for(long i=2;i<=max;i++)npn[i] = false;
                pn.clear();
        }

        return 0;
}

C++: #include <stdio.h>
#include <algorithm>  // fill 関数を使うのに必要
#define PN_NUM 1000000    // 1000000 未満の非負数を素数判定する
using namespace std;

bool prime_number[PN_NUM];

// エラトステネスのふるい
void set_prime_number(bool* array) {

  fill(array, array + PN_NUM, true); // array の全要素を true にする
  array[0] = array[1] = false; // 0 と 1 は素数ではない
  for (int i = 2; i < PN_NUM; i++) {
    if (!array[i])
      continue;
    for (int j = i * 2; j < PN_NUM; j += i) {
      array[j] = false; // 素数の倍数は，素数ではない
    }
  }

}

int main() {
  int cnt, n;

  set_prime_number(prime_number);
  while (scanf("%d", &n) != EOF) {
    cnt = 0;
    for (int i = 0; i <= n; i++) {
      if (prime_number[i]) // i が素数ならば
        cnt++;             // cnt をインクリメント
    }
    printf("%d\n", cnt);   // cnt を出力
  }

  return 0;
}

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

bool isprime(int number, const std::vector<int>& primeset)
{
	for (std::vector<int>::const_iterator p = primeset.begin(); p != primeset.end(); ++p) {
		if (number % *p == 0) {
			return false;
		}
	}
	return true;
}

int resolve(int number)
{
	std::vector<int> primeset;
	for (int i = 2; i <= number; ++i) {
		if (isprime(i, primeset)) {
			primeset.push_back(i);
		}
	}
	return static_cast<int>(primeset.size());
}

int main()
{
	int input;
	while (std::cin >> input) {
		std::cout << resolve(input) << std::endl;
	}

	return 0;
}

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

int main(){
	static int n;
	static int prime[MAX],i,j;
	static int count;
	static bool flag;

	while((cin >> n)!= NULL){
		count = 0;
		for(i = 3; i <= n; i+=2){
			flag = true;
			for(j = 0; j < count; j++){
				if(i % prime[j] == 0){
					flag = false;
					break;
				}
				if(prime[j] * prime[j] > i) break;
			}
			if(flag == true){
				prime[count++] = i;
			//	cout << count << endl;
			}
		}
		if(n > 1)	count++; //2
		cout << count << endl;
		//delete[] prime;
	}
	return 0;
}

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

int main(){
  bool prime[1000000] = {};
  int sum[1000000]; sum[0] = sum[1] = 0; sum[2] = 1;
  for(int i = 3 ; i < 1000000 ; i += 2 ){
    sum[i] = sum[i + 1] = sum[i - 1];
    if(!prime[i]){
      for(int j = i + i + i ; j < 1000000 ; j += i + i ){
        prime[j] = true;
      }
      sum[i]++;
      sum[i+1]++;
    }
  }

  int n;
  while(cin >> n){
    cout << sum[n] << endl;
  }
}

C++: #include<iostream>
using namespace std;
int sushu(int a)
{
	int flag = 1;
	for (int i = 2; i < sqrt(a)+1; i++)
	{
		if (a%i == 0)
		{
			flag = 0;
			break;
		}
	}
	return flag;
}
int main()
{
	int n;
	while (cin >> n)
	{
		int ans = 0, flag = 1;
		if (n == 1)
			cout << ans << endl;
		else
		{
			for (int i = 2; i <= n; i++)
			{
				flag = sushu(i);
				if (flag)
					ans++;
			}
			cout << ans+1 << endl;
		}
	}
	return 0;
}

C++: #include <stdio.h>

int main (void){
	int number, i, j, count=0, flag=0, d;
	
	while(scanf("%d", &number)!=EOF){
		count=0;
		int n[number];
		for(i=0; i<number; i++){
			n[i]=i+1;
		}
		
		n[0]=-1;
		for(i=0; i<number; i++){
			if(n[i]!=-1){
				d=i+1;
				for(j=d, flag=0; j<=number; j+=d, flag++){
					if(flag!=0){
						n[j-1]=-1;
					}
				}
			}
		}
	
		for(i=0; i<number; i++){
			if(n[i]!=-1){
				//printf("%d\n", n[i]);
				count++;
			}
		}
		printf("%d\n", count);
	}
	
	return 0;
}

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

bool isPrime(int);

int main() {
	int n, p;
	while (cin >> n) {
		p = 0;
		if (cin.eof())
			return 0;
		for (int i = 2; i <= n; i++) {
			if (isPrime(i))
				p++;
		}
		cout << p << endl;
	}
	return 0;
}

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

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  for(int i = 0; i < 30; i++){
    scanf("%d",&n);
    printf("%d\n",sum[n]);
  }
  return 0;
}

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

using namespace std;

static const int MAX = 999999;

vector<bool> v(int(sqrt(MAX)), false);

using namespace std;

int main(){
    v[1] = true;
    for (size_t i = 2; i < v.size(); ++i){
        int flag = 0;
        if ((i+1) % 2 == 0) continue;
        for (size_t j = 3; j < i; ++j){
            if ((i+1)%j == 0) {flag = 1; break;}
        }
        if (flag != 1) v[i] = true;
    }
    
  
    int input;
    while (cin >> input){
     int count(0);
     for (int i = 0; i < input; ++i){count+=v[i]==true;}
     cout << count << endl;
    }
}

C++: #include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long int ll;

int main()
{
	bool a[1000001];
	for(int i=1;i<=1000000;i++)a[i]=true;
	for(int i=2;i*i<=1000000;i++){
		for(int j=2;i*j<=1000000;j++){
			a[i*j]=false;
		}
	}
    int n;
	while(cin >> n){
		int ans=-1;
		for(int i=1;i<=n;i++){
			if(a[i])ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}

C++: #include <stdio.h>
#include <string.h>
int main(void){
    int n=999,a,b,c;
    char x[1000000];
    memset(x,0,sizeof(x));
    for(a=2,c=0;a<=n;a++){
        if(x[a]){x[a]=c;continue;}
        x[a]=++c;
        for(b=a*2;b<=n;b+=a)x[b]=-1;
    }
    while(~scanf("%d",&n)){
        printf("%d\n",x[n]);
    }
    return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int p[1000010];

int main(){
	p[0]=p[1]=1;
	rep(i,1000000){
		if(p[i]==0)
			for(int j=2*i;j<1000000;j+=i)
				p[j]=1;
	}
	int n;
	for(;cin>>n;){
	int r=0;
	rep(i,n+1)
	if(p[i]==0)r++;
	cout<<r<<endl;
	}
	return 0;
}