Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include<stdio.h>

int main(void){
  int n;
  while(scanf("%d",&n)!=EOF){
    if(n==1){
      printf("%d\n",0);
      break;
    }
    int p[1000000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

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

int main(){
  int prime[100000];
  int isprime[1000000];
  memset(isprime,1,sizeof(isprime));
  isprime[0]=0;
  isprime[1]=0;
  
  for(int i=2;i<1000000;i++){
    if(isprime[i]){
      for(int j=i*2;j<1000000;j+=i){
	isprime[j]=0;
      }
    }
  }
  int pi;
  for(int i;i<1000000;i++){
    if(isprime[i]==1){
      prime[pi]=i;
      pi++;
    }
  }

  int n;
  while(cin>>n){
    int ans;
    while(prime[ans]<=n){
      ans++;
    }
    cout<<ans<<'\n';
  }
  return 0;
}

C++: #include<cstdio>
using namespace std;
const int N = 1000000;

int main(){

  int IsPrime[N];
  IsPrime[0] = -1;
  IsPrime[1] = -1;
  for(int i=2; i*i<=N;i++){
    if(IsPrime[i]==0){
      IsPrime[i] = 1;
      for(int j=2*i; j<=N; j+=i)
        IsPrime[j] = -1;
      }
  }
  int max;
  while(~scanf("%d",&max)){
    int count=0;
    for(int i=1; i<max+1; i++)
      if(IsPrime[i]==1) count++;
    printf("%d\n",count);
  }
}

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

using namespace std;
int sieve[1000005]= {0}, n, i, j, cnt=0;;
int main()
{
    while(cin>>n)
    {
        cnt=0;
        for(i=2; i<=n+2; i++)
        {
            if(!sieve[i])
            {
                for(j=2*i; j<=n+1; j+=i)
                {
                    sieve[j]=1;
                }
            }
        }

        for(i=2; i<=n; i++)
        {
            if(!sieve[i])
            {
                cnt++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
void eratosthenes(V &v) {
  v[0] = v[1] = false;
  loop(i, 2, v.size()) v[i] = true;
  for (int i = 2; i * i < v.size(); i++) {
    if (v[i]) {
      for (int j = i * 2; j < v.size(); j += i) {
        v[j] = false;
      }
    }
  }
}

void solve() {
  vi v(1000000);
  eratosthenes(v);
  loop(i, 1, v.size()) v[i] += v[i - 1];
  int n;
  while (cin >> n) cout << v[n] << endl;
}

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

int main() {
	int n;
	while(cin >> n && n != EOF) {
		bool* prime = new bool[n+1];
		int count = 0;
		for(int i = 2; i < n; ++i) {
			prime[i] = true;
		}
		prime[0] = prime[1] = false;
		
		for(int i = 0; i < n; ++i) {
			if(prime[i]) {
				count++;
				for(int j = 2 * i; j < n; j += i) {
					prime[j] = false;
				}
			}
		}
		
		cout << count << endl;
		delete[] prime;
	}
}

C++: //0009 Prime Number
//100¢Ì³Ì®nªüÍ³ê½Æ«AnÈºÌfª¢­ç é©oÍ·évOðì¬¹æ
//s²ÆÉêÂÌ®nªüÁÄ¢é@EOFªüÍÌIíèÅ é

#include<iostream>
#include<bitset>
using namespace std;

int main(void)
{
	const int N = 1000000;	//100ÂmÛ
	bitset<N> isPrime;
	int n;
	int i, j;

	while( cin >> n)
	{
		//â¿ðg¢Ü·
		isPrime.set();
		isPrime[0] = isPrime[1] = false;
		for(i = 2; i <= n; i++)
		{
			if(isPrime[i])
			{
				for(j = 2*i; j <= n; j+=i)
				{
					isPrime[j] = false;
				}
			}
		}

		int count = 0;
		for(i = 0; i <= n; i++)
			if(isPrime[i])
				count++;

		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>

int main() {
	// Prime Data Set
	char p[1000000] = {0};
	p[1] = 1;
	for( int i=2; i<1000; i++) if(!p[i]) for( int j=i+i; j<1000000; j+=i) p[j] = 1;
	
	int n;
	int sum;
	while( std::cin >> n) {
		sum = 0;
		for( int i=1; i<n; i++) {
			if(!p[i]) sum++;
		}
		std::cout << sum << std::endl;
	}
}

C++: 
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <set>
#include <map>
#define INF 100000
using namespace std;
typedef long long int ll;

int main(){
    vector<ll> era(10000000,0);
    for (int i=1; i<era.size(); i++) {
        era[i]=i;
    }
    for (int i=2; i<era.size(); i++) {
        if (era[i]!=0) {
            ll q = i + era[i];
            while (q<era.size()) {
                era[q]=0;
                q += era[i];
            }
        }
    }
    int n;
    while (cin >> n) {
        int ans=-1;
        for (int i=1; i<=n; i++) {
            if (era[i]==i) {
                ans++;
            }
        }
        cout << ans <<endl;
    }
}

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

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,max;
	int count[N_MAX];
	bool so[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		so[i]=true;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	so[0]=so[1]=0;
	for(soi=0,i=2;i<=1000;i++){
		if(so[i]==0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=false;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

C++: #include<cstdio>

long prim[1000100];
long prima[1000100];
    
int main() {
    long n, i, x = 0;
    for (i = 2; i <= 1000000; i++) {
        prim[i] = i;
    }
    for (i = 2; i <= 1000000; i++) {
        if (prim[i] != 0) {
                  prima[x] = prim[i];
                  x+= 1;
                  int j = i;
                  while ( j <= 1000000) {
                        prim[j] = 0;
                        j+= i;
                  }
        }
    }
    while (scanf("%ld", &n) != EOF) {
          long a = 0;
          while ( prima[a] <= n) {
                a++;
          }
          printf("%ld\n", a);
    }
    return 0;
}