Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

C++: #include <iostream>
#include <cmath>
 
bool CheckPrimeNumber(int number) {
    int max = (int)std::sqrt(number);
    for (int i=3; i<=max; i+=2)
        if (number % i == 0)
            return false;
    return true;
}
 
int main() {
    int n, cnt;
    while (std::cin >> n) {
        if (n < 2) {
	cnt = 0;
        } else if (n == 2) {
	cnt = 1;
        } else {
        	cnt = 1;
        	for (int i=3; i<=n; i+=2)
		if (CheckPrimeNumber(i))
			cnt++;
        }
        std::cout << cnt << std::endl;
    }
    return 0;
}

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


int main() {
  int max =0;
  vector<int> ns;
  vector<int> nums;
  while(!cin.eof()){
    int n=0;
    cin >> n;
    // 求める数の最大値を出す
    max = max > n ? max : n;
    // nsには入力が一覧で入る
    ns.push_back(n);
  }
  for(int i =0 ;i <= max;i++) {
    // 0-maxまで1をいれる。
    nums.push_back(1);
  }

  // 素数の可能性が無いものについては0を入れていく (n >=2)
  for(int i =2 ;i <= max;i++) {
    if(nums[i]==0) {
      continue;
    }
    // 素数の 2～倍はすべて素数ではないのでnを入れる
    for(int ii=i*2 ; ii<=max ; ii+=i) {
      nums[ii] = 0;
    }
  }

  for(int i=0;i<ns.size()-1;i++) {
    int count = 0;
    // 素数の数を数え上げ
    for(int ii=2 ; ii <= ns[i] ; ii++) {
      if(nums[ii]==1) count++;
    }
    cout<<count<<endl;
  }
}

C++: #include <iostream>

using namespace std;

int main()
{
	int i, j, n;
	int count = 0;

	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			for (j = 2; j < i; j++) {
				if (i % j == 0) {
					break;
				}
			}
			if (i == j) {
				count++;
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

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

int main(void) {
  int table[MAX_NUM + 1] = {0};
  for(int i = 2; i < MAX_NUM; i++) {
    for(int j = i * 2; j < MAX_NUM; j = j + i) {
      table[j] = 1;
    }
  }

  int num;
  int ans = 0;
  while(cin >> num) {
    for(int i = 2; i <= num; i++) {
      if(table[i] == 0) {
        ans++;
      }
    }
    cout << ans << endl;
    ans = 0;
  }

  return 0;
}

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

int main(){

	int n, i, j, prmnum;
	bool prm = true;
	while(cin>>n){
		prmnum = 0;
		for( i=2;i<=n;i++ ){
			prm = true;
			for( j=2;j<i;j++ ){
				if( i%j == 0 ){
					prm = false;
					break;
				}
			}
			if(prm)prmnum++;
		}
		cout << prmnum << endl;
	}
	return 0;
}

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

int main(){
    vector<int> prime;
    int n;
    for(int i=2;i<1000000;i++){
        bool isprime=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                isprime=false;
                break;
            }
        }
        if(isprime) prime.push_back(i);
    }
    while(cin >> n){
        for(int i=0;i<prime.size();i++){
            if(prime[i]>n){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
  int MAX = 1000000;
  int n;
  int cnt=0;
  vector<bool> num(n);
  
  for(int i=0; i<MAX; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;

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

  while(cin >> n){
    cnt = 0;
    for(int i=0; i<n; i++){
      if(num[i]) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = 998244353;
const double EPS = 1e-9;

bool s[1000000] = {};
int sosu[1000000] = {};
void erast(){
  memset(s,1,sizeof(s));
  s[1] = false;
  s[0] = false;
  REP(i,2,1000){
    if(s[i]){
      REP(j,2,1000000){
        if(i*j>=1000000) break;
        s[i*j] = false;
      }
    }
  }
  REP(i,2,1000000) sosu[i] = sosu[i-1]+s[i];
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    erast();
    int n;
    while(cin >> n){
      cout << sosu[n] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
    int MAX = 1000000;
    int lim = sqrt(MAX);
    vector<int> is_prime(MAX, 1);
    is_prime[0] = is_prime[1] = 0;
    for(int i = 2; i < MAX; ++i) {
        if(is_prime[i])
            if(i < lim) 
                for(int j = i*i; j < MAX; j += i) is_prime[j] = 0;
    }

    vector<int> primes;
    for(int i = 0; i < MAX; ++i)
        if(is_prime[i]) primes.push_back(i);

    int n;
    while(cin >> n) 
        cout << upper_bound(primes.begin(), primes.end(), n)-primes.begin() << endl;
    return 0;
}

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

const int MX = 1000000;
bool prime[MX];
int cnt[MX];

int main() {
    for (int i=0; i<MX; ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for (int i=2; i<MX; ++i) {
        if ( ! prime[i]) continue;
        for (int j=i; (long long)i*j<MX; ++j) {
            prime[i*j] = false;
        }
    }
    cnt[0] = 0;
    for (int i=1; i<MX; ++i) {
        cnt[i] = cnt[i-1] + prime[i];
    }
    int N;
    while (cin >> N) {
        cout << cnt[N] << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  int n;
  
  while(1) {
    cin >> n;
    if(cin.eof()) {
      break;
    }
    int m = (int)sqrt(n);
    
    vector<bool> h(n+1, true);
    h[0] = false;
    h[1] = false;
    
    for(int i = 2; i <= m; i++) {
      if(h.at(i)) {
	for(int s = 2; s*i < h.size(); s++) {
	  if(h.at(s*i))
	    h[s*i] = false;
	}
      }
    }
    
    int ans=0;
    for(auto f : h) {
      if(f)
	ans++;
    }
    cout << ans << endl;
  }
  
  return 0;
}

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

using namespace std;

int solist[999999];

int main(int argc, char* argv[])
{
	int num;
	int count;
	int i, j;
	int val;

	count = 8;
	solist[0] = 2;
	solist[1] = 3;
	solist[2] = 5;
	solist[3] = 7;
	solist[4] = 11;
	solist[5] = 13;
	solist[6] = 17;
	solist[7] = 19;

	for (num = 3; num < 1000000; num += 2) {
		for (i = 0; i < count; i++) {
			if (num % solist[i] == 0) break;
		}
		if (i == count) solist[count++] = num;
	}

	while (cin >> val) {
		for (i = 0; i < count; i++) {
			if (solist[i] > val) {
				cout << i + 1 << endl;
				break;
			}
		}
		if (i == count) cout << count << endl;
	}
	
	return 0;
}