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

int main(){
    int n;
    while(cin >> n){
        int numOfPrime = 0;
        bool isPrime[n-1];
        for(int i=2;i<=n;++i){
            isPrime[i-2] = true;
        }
        for(int i=2;i<=sqrt(n);++i){
            if(!isPrime[i-2]){
                continue;
            }
            for(int j=i;j<=n;++j){
                if(j%i == 0 && i != j){
                    isPrime[j-2] = false;
                }
            }
        }
        for(int i=2;i<n;++i){
            if(isPrime[i-2]){
                ++numOfPrime;
            }
        }
        cout << numOfPrime << endl;
    }
}

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

using namespace std;

int main(){
  int i;
  vector<int> knownprime;
  vector<int> ans;
  bool flag;

  while(cin >> i){
    if(cin.eof()){
      break;
    }
    knownprime.clear();
    for(int d = 2; d <= i; d++){
      flag = true;
      for(int& p : knownprime){
	// ?????§??????????????£??????????´???°??§?????£??????????????¨?????§?????????????????°??°???????´???°??¨??????
	if(d%p == 0){
	  flag = false;
	  break;
	}
      }
      if(flag){
	knownprime.push_back(d);
      }
    }
    ans.push_back(knownprime.size());
  }
  for(int& d : ans){
    cout << d << endl;
  }

}

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

int prime[1000000];
void initTbl(){
	//sieve of Eratosthenes
	// 0 : prime
	// 1 : not prime
	memset(prime, 0, sizeof(prime));
	prime[0] = 1;
	prime[1] = 1;

	int limit = 1000000;
	for(int i=4; i<limit; i+=2){
		prime[i] = 1;
	}

	for(int j=3; j*j<=limit; j+=2){
		for(int k=j; j*k<=limit ;k+=2){
			prime[j*k] = 1;
		}
	}
}

//0009
int main()
{
	int n=10;
	initTbl();

	while(cin >> n){
		int cnt = 0;

		for(; n>0; n--){
			if(!prime[n])
				++cnt;
		}
		cout << cnt << endl;

	}
  return 0;
}

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

int main(){
  static bool cmp[1000000] = {true};
  // cout << cmp[3] << cmp[2] << cmp[5]<<endl;
  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<iostream>
using namespace std;
int main(){
  bool num[1000000] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]) for(int j=i*i; j<1000000; j+=i) num[j] = true;
  }
  int n;
  while(cin >>n){
    int ans = 0;
    for(int i=2; i<=n; i++) if(!num[i]) ans++;
    cout <<ans<<endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
        int n;

        while (cin >> n) {
                bool *isPrime = new bool[n + 1];
                isPrime[0] = false;
                isPrime[1] = false;
                for (int i = 2; i < n + 1; i++) {
                        isPrime[i] = true;
                }
                for (int i = 2; i <= (int)sqrt(n); i++) {
                        if (isPrime[i]) {
                                for (int j = 2; j <= n / i; j++) {
                                                isPrime[i * j] = false;
                                }
                        }
                }
                int ans = 0;
                for (int i = 2; i <= n; i++) {
                        if (isPrime[i]) {
                                ans++;
                        }
                }
                cout << ans << endl;
                delete [] isPrime;
        }

        return 0;
}

C++: #include <iostream>
using namespace std;
bool num[500000];
int main()
{
	int n;
	while(cin >> n)
	{
		num[0]=num[1]=true; for(int i=2;i<=n;i++) num[i]=false;
		int ans=0;
		for(int i=2;i<n;i++)
		{
			if(num[i]==false)
			{
				for(int j=i*2;j<=n;j+=i) num[j]=true;
			}
		}
		for(int j=2;j<=n;j++) if(num[j]==false) ans++;
		cout << ans << '\n' ;
	}
}

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

int main()
{
	int n, i, k, j, h;
	bool flag = false;

	for(i=0; i<30; i++)
	{
		cin >> n;
		h = 0;
		for(k = 2; k <= n; k++)
		{
			flag = false;
			for(j = 2; j <= sqrt(k); j++)
			{
				if(k % j == 0)
				{
					flag = true;
					break;
				}
			}
			if(flag == false)
				h++;
		}
		cout << h << endl;
	}
}

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

int main(){
  int n;
  while (std::cin >> n) {
    int count=0;//素数の数
    for(int i=2;i<=n;i++){
      if(i==2){
        count++;
        continue;
      }
      int flag=0;
      for(int j=2;j<=sqrt(i);j++){
        if(i%j==0){
          flag=1;
          break;
        }
      }
      if(flag==0){
        count++;
      }
    }
    std::cout << count << '\n';
  }

}