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>
using namespace std;
#define L long long int
int main(){
int n,ans,i,j;
while(cin>>n){
	ans=0;
	for(i=2;i<=n;i++){//search for 2 to n
		for(j=2;j<=i;j++)if(i%j==0)break;
		if(j==i)ans++;
	}
	cout<<ans<<endl;
}
system("pause");
return 0;
}

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

int main()
{
  int i, j;
  int n;
  int ans;
  int count;

  ans = 0;

  cin >> n;
  for (i = 2; i <= n; i++){
    count = 0;
    for (j = 1; j <= i; j++){
      if (i % j == 0){
        count++;
      }
    }

    if (count == 2){
      ans++;
    }
  }
  cout << ans << "\n";

  return (0);
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstdint>
#include <cstring>
#include <cctype>
#include <iostream>
#include <sstream>
#include <vector>
#include <list>
#include <deque>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long long ll;
const double PI = 3.141592653589793238462643383279502884L;
const int LARGE_INT = 1000000007;
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(auto i = (c).rbegin(); i != (c).rend(); i++)
#define repfn(i,a,cont,next) \
  for(auto i = (a); [=](){return(cont);}(); i = [=](){return(next);}())
#define repby(i,a,b,s) repfn(i,a,i<b,i+s)
#define repab(i,a,b) repby(i,a,b,1)
#define rep(i,b) repab(i,0,b)
#define pb push_back
#define sz(c) int((c).size())

int check(vector<bool> &v, int from, int to)
{
  int i;
  for (i = from + 1; i*i <= to && i*i < sz(v); i++) {
    if (v[i]) {
      for (int j = 2; i*j <= to && i*j < sz(v); j++) {
        v[i*j] = false;
      }
    }
  }
  return i - 1;
}

int count(vector<bool> &v, int to)
{
  int res = 0;
  repab (i, 2, to+1) {
    if (i >= sz(v))
      break;
    if (v[i])
      res++;
  }
  return res;
}

int main(int argc, char **argv)
{
  vector<bool> v(1000000);
  int done;

  rep (i , 1000000) {
    v[i] = true;
  }

  int n;
  done = 1;
  while (cin >> n) {
    done = check(v, done, n);
    cout << count(v, n) << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#define N 1000000

int main() {
	int ipt;
	int root;
	int cnt = 0;
	int A[N];
	for (int i = 1; i <= N; i++) {
		A[i] = i;
	}
	for (int pos = 2; pos <= N; pos++) {
		root = A[pos];
		if (!root)continue;
		for (int k = 2; k*root <= N; k++) {
			A[k*root] = 0;
		}
	}

	while(1) {
		scanf("%d", &ipt);
		for (int i = 2; i <= ipt; i++) {
			if (A[i] != 0)cnt++;
		}
		printf("%d\n", cnt);
		cnt = 0;
	}

	return 0;
}

C++: #include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <complex>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<double> VEC;
typedef vector<VEC> MAT;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<int, PII> TIII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
//container util

//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define MT(a,b,c) MP(a, MP(b, c))
#define T1 first
#define T2 second.first
#define T3 second.second.first
#define T4 second.second.second

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define EPS 1.0e-9

char bits[1000000];
LL primes[100000], n_primes; 
int cnt[1000000];

void sieve(){
	int i, j;
	memset(bits, 1, 1000000);
	bits[0] = bits[1] = 0;
	for (i = 0; i < sqrt(1000000.0)+1; i++)
		if (bits[i])
			for (j = i * i; j < 1000000; j += i)
				bits[j] = 0;
	for (i = j = 0; i < 1000000; i++)	
		if (bits[i]) primes[j++] = i;
	n_primes = j;
}

int main(){
	sieve();
	FOR(i,1,1000000){
		cnt[i] = cnt[i-1];
		if(bits[i])cnt[i]++;
	}
	int n;
	while(cin>>n)cout << cnt[n] << endl;
	return 0;
}

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

using namespace std;

class Prime {
private:
  vector<long long> divisor;
  
public:
  Prime(long long n) {
    for (long long i = 0; i < n; ++i) divisor.emplace_back(i);
    for (long long i = 2; i <= n / i; ++i) if (divisor[i] == i) {
      for (long long j = i * i; j < n; j += i) divisor[j] = i;
    }
  }
  
  bool isPrime(long long n) {
    if (n <= 1) return false;
    if (n < (long long)divisor.size()) return divisor[n] == n;
    for (long long i = 2; i <= n / i; ++i) if (n % i == 0) return false;
    return true;
  }
  
  vector<long long> factor(long long n) {
    vector<long long> res;
    for (long long i = 2; i <= n / i && n >= (long long) divisor.size(); ++i) {
      while (n % i == 0) {
        res.emplace_back(i);
        n /= i;
      }
    }
    if (n >= (long long)divisor.size()) {
      res.emplace_back(n);
    } else {
      while (n > 1) {
        res.emplace_back(divisor[n]);
        n /= divisor[n];
      }
    }
    sort(res.begin(), res.end());
    return res;
  }
  
  vector<long long> divisors(long long n) {
    vector<long long> res;
    for (long long i = 2; i <= n / i && n >= (long long) divisor.size(); ++i) {
      if (n % i) continue;
      res.emplace_back(i);
      while (n % i == 0) n /= i;
    }
    if (n >= (long long)divisor.size()) {
      res.emplace_back(n);
    } else {
      while (n > 1) {
        long long d = divisor[n];
        res.emplace_back(d);
        while (n % d == 0) n /= d;
      }
    }
    sort(res.begin(), res.end());
    return res;
  }
};

int main() {
  Prime prime(1000000);
  array<int, 1000000> sum;
  sum[0] = 0;
  for (int i = 1; i < 1000000; ++i) sum[i] = sum[i - 1] + prime.isPrime(i);
  int n;
  while (cin >> n) cout << sum[n] << endl;
}

C++: #include <iostream>
using namespace std;
 
bool isprime(int n) { //??´????°?????????°true
    for(int i=2; i*i <= n; i++) {
        if(n%i==0) return false;
    }
    return n != 1;
}
 
int main() {
int n;
while(cin >> n) {
int cnt = 0;
for(int i=2; i<=n; i++) if(isprime(i)) cnt++;
cout << cnt << endl;
}
return 0;
}