Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: #include <iostream>
using namespace std;
 
 
int main()
{
    int max = 10000;
    int prime[max];
    
    fill(prime, prime + max, 1);
    prime[0] = 0;
    prime[1] = 0;
    for (int i = 2; i < max; i++) {
        if (prime[i]) {
            for (int j = 2*i; j < max; j += i) {
                prime[j] = 0;
            }
        }
    }
    
    for(int i = 1;i < max; i++){
	    prime[i] = prime[i] + prime[i-1];
    }
    
    int aaa;
    while (cin >> aaa) {
	cout << prime[aaa] << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
bool num[1000000]={true,true};
int main(){
  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++: 
/* vo00_09.cpp */

#include <iostream>
using namespace std;

const int N = 1000000;
int prime[N];

void init();

int main()
{
	init();

	int n;
	while (cin >> n) {
		
		cout << prime[n] << '\n';

	}

	return 0;
}

void init()
{
	for (int i = 0; i < N; ++i) { prime[i] = 1; }

	prime[0] = prime[1] = 0;

	int count = 0;
	for (int i = 2; i < N; ++i) {
		if (prime[i]) {
			for (int j = i * 2; j < N; j += i) { prime[j] = 0; }
			count++;
		}
		
		prime[i] = count;
	}
}

C++: #include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;

int main(void) {
	while (1) {
		int n;
		int count = 1;
		cin >> n;
		if (n == 1) {
			cout << 0 << endl;
		}
		else if (n == 2) {
			cout << 1 << endl;
		}
		else {
			for (int t = 3; t <= n; t += 2) {
				FOR(i, 2, t - 1) {
					if (t%i == 0) {
						break;
					}
					if (i == t - 1) {
						count++;
						break;
					}
				}
			}
			cout << count << endl;
		}
	}
	
	
	return 0;
}

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

int main() {
	int a;
	while (cin >> a, a) {
		int sosuu = 0;
		if (a > 1)sosuu++;
		if (a > 2)sosuu++;
		for (int b = 5; b <= a; b+=2) {
			for (int c = 3;; c+=2) {
				if (b%c==0)break;
				if ((c + 1)*(c + 1) > b) { sosuu++;   break; }
			}
		}
		cout << sosuu << endl;
	}
}

C++: #include<iostream>

using namespace std;

int main(){
	int n;
	bool p[1000000] = { true };
	int ans[1000000] = { 0 };
	p[0] = false;
	p[1] = false;

	for (int i = 2; i < 1000; i++){
		if (p[i]){
			for (int j = i*i; j < 1000000; j+=i){
				p[j] = false;
			}
		}
	}

	for (int i = 0; i < 1000000; i++){
		ans[i] += p[i];
	}

	while (cin >> n)
		cout << ans[n] << endl;

}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#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-8;
typedef long long ll;

const int SIZE = 1000000;
bool is_prime[SIZE];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		if (n < 2)
			puts("0");
		else
			printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin() - 1);

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
        int n;
        int d; //素数を入れるための添字
        bool count; //割りきれるかどうかの判定
        int number[400000]; //素数を入れておく
        number[0] = 2;
        
        
 
                d = 0;
                for(int i = 3; i <= n; i++){
                        count = true;
                        for(int j = 0; j <= d; j++)
                                if(i % number[j] == 0)
                                        count = false;
                        if(count == true){
                                d++;
                                number[d] = i;
                        }
                
        cout << d+1 << endl;
        }
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<vector>
#include<cmath>
#define mem0(x) memset(x,0,sizeof(x))
#define memff(x) memset(x,0xff,sizeof(x))
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repp(i,a,b) for(int i=a;i<=b;i++)
#define per(i,b,a) for(int i=b;i>a;i--)
#define perr(i,b,a) for(int i=b;i>=a;i--)
#define MAX_N 5050
#define MAX_M 5050
#define MAX_P 1000010
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;
map<int,int> m;
const int INF=1<<29;
const int MOD=1e9+7;
int par[MAX_N];
int rank[MAX_N];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int GCD(int a,int b){if(b==0) return a;return GCD(b,b%a);}
void init(int n){rep(i,0,n){par[i]=i;rank[i]=0;}}
int find(int x){return x==par[x]?x:par[x]=find(par[x]);}
void unite(int x,int y){x=find(x);y=find(y);if(x==y) return;if(rank[x]<rank[y]){par[x]=y;}else{par[y]=x;if(rank[x]==rank[y])rank[x]++;}}
bool same(int x,int y){return find(x)==find(y);}
struct node{int x,y;};
bool cmp(int x,int y){return x>y;}
bool ccmp(node x1,node x2){return x1.x>x2.x;}
LL mod_pow(LL x, LL n,LL mod){LL res=0;while(n>0){if(n&1) res=res*x%mod;x=x*x%mod;n>>=1;}return res;}
int prime[MAX_P];
bool is_prime[MAX_P];
int x;
int sieve(int  n)
{
    int p=0;
    repp(i,0,n)
    {
        is_prime[i]=true;
    }
    is_prime[0]=is_prime[1]=false;
    repp(i,2,n)
    {
        if(is_prime[i])
        {
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i)
            is_prime[j]=false;
        }
    }
    return p;
}
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    while(~scanf("%d",&x))
    {
        printf("%d\n",sieve(x));
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define MAX 1000000
#define SQRTMAX 1000
void seive_prime(bool seive[])
{
	for(int i=2;i<=SQRTMAX;i++) {
		if(seive[i] == false) {
			for(int j=i*2;j<=MAX;j+=i) {
				seive[j]=true;
			}
		}
	}
}
int main() {
	int n;
	bool sieve[MAX+1] = {false};
	// エラトステネスの篩
	seive_prime(sieve);
	
	while(cin >> n) {
		int cnt = 0;
		for(int i=2;i<=n;i++) {
			if(sieve[i] == false)
				cnt++;
		}
		cout << cnt << endl;
	}
}