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 <cstdio>
#include <iostream>

using namespace std;

bool is_prime(const unsigned n);


int main(){
	int n;

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

		for(int number=2;number<=n;number++){
			if(is_prime(number))ans++;
		}
		printf("%d\n",ans);
	}


	return 0;
}

bool is_prime(const unsigned n){
    switch(n){
        case 0: 
        case 1: return false;
        case 2: 
        case 3: return true;
    } 

    if(n%2 == 0) return false;
    if(n%3 == 0) return false;

    if(n%6 != 1 && n%6 != 5) return false;

    for(unsigned i=5;i*i<=n;i+=6){
        if(n%i     == 0) return false;
        if(n%(i+2) == 0) return false;
    }

    return true;}

C++: #include <cstdio>  
#include <iostream>  
using namespace std;  
int prime[1000005];  
bool is_prime[1000005];  
int seve(int n)  
{  
    int p=0;  
    for(int i=0;i<=n;i++)  
        is_prime[i]=true;  
    is_prime[0]=is_prime[1]=false;  
    for(int i=2;i<=n;i++)  
    {  
        if(is_prime[i])  
        {  
            prime[p++]=i;  
            for(int j=2*i;j<=n;j+=i)  
                is_prime[j]=false;  
        }  
    }  
    return p;  
}  
int main(void)  
{  
    int n;  
    while(scanf("%d",&n)!=EOF)  
    {  
        printf("%d\n",seve(n));  
    }  
    return 0;  
}

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

using namespace std;

int main(){
  
  int n;
  
  while(cin >> n){
    bool d[1000000];
    int ans = 0;
    
    for(int i = 1;i <= n;i++){
      d[i] = true;
    }
    d[1]  = false;
    
    for(int i = 1;i <= n;i++){
      if(d[i] == true){
	ans++;
	for(int j = 1;j*i <= n;j++){
	  d[i*j] = false;
	}
      }
    }
    
    printf("%d\n",ans);
  }
  
  return 0;
  
}

C++: #include <iostream>
using namespace std;
bool prime[1000000];
void sieve() {
    fill_n(prime, 1000000, true);
    for (int i=2; i<=1000; ++i) {
        if (prime[i]) {
            for (int j=i; i*j<1000000; ++j) {
                prime[i*j] = false;
            }
        }
    }
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);

    sieve();
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i=2; i<=n; ++i) {
            if (prime[i]) {
                cnt ++;
            }
        }
        cout << cnt << "\n";
    }
    return 0;
}

C++: j,a['   '],s;main(i){for(;++i<1e6||~scanf(s="%d\n",&j)&&printf(s,a[j]);)for(a[i]=s+=!a[j=i];j<1e6;a[j+=i]=1);}

C++: #include<iostream>
using namespace std;
main(){
int n;
    while(cin>>n){
        cout<<n<<endl; 
   }
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  int a[1000000];
  int N=1000000;
  for(int i=0 ; i<N;i++)
    a[i]=1;

  for(int i=2; i<sqrt(N);i++){
    if(a[i]){
      for(int j=0 ; i*(j+2)<N;j++){
          a[i*(j+2)]=0;
      }
    }
  }
  int n;
  while(cin >>n){
  int sum=0;
  for(int i=2;i<=n;i++)
        sum+=a[i];
        cout << sum<<endl;
  }
}

C++: #include <iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn=1e6+5;
int prime[maxn];
bool p[maxn];
int cnt=0;
void is_prime()
{
    memset(p,true,sizeof(p));
    p[0]=p[1]=false;
    for(int i=2;i<=maxn;i++)
        if(p[i]) {
            prime[cnt++]=i;
            for(int j=i*i;j<=maxn;j+=i)
                 p[j]=false;
        }
}
int main()
{
    is_prime();
    int n;
    while(scanf("%d",&n)==1)
    {
        int k=lower_bound(prime,prime+cnt,n)-prime;
        if(prime[k]==n) k++;
        printf("%d\n",k);
    }
    return 0;
}

C++: #include <iostream>
#include <map>
using namespace std;
#define MAX_N 999999
int main()
{
    int n;
    bool notPrime[MAX_N+1];
    int count[MAX_N+1];
    for (int i = 2 ; i <= MAX_N ; i++)
    {
        if (!notPrime[i])
        {
            for (int g = i+i ; g <= MAX_N ; g += i)
            {
                notPrime[g] = true;
            }
        }
    }
    int cnt = 0;
    count[1] = 0;
    for (int g = 2 ; g <= MAX_N ; g++)
    {
        if (!notPrime[g])
            cnt ++;
        count[g] = cnt;
    }
    while (cin >> n)
    {
        cout << count[n] << endl;
    }
    
}

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

using namespace std;

bool judge_Prime_num(const int& num) {
	if (num < 2)
		return false;
	else if (num == 2)
		return true;
	else if (num % 2 == 0)
		return false;

	double sqrtnum = sqrt(num);
	for (int i = 3; i <= sqrtnum; i += 2) {
		if (num%i == 0)
			return false;
	}
	return true;
}

int main() {
	int n;
	while (cin >> n) {
		//clock_t start = clock();
		int tmp = n;
		int cnt = 0;
		while (tmp > 1) {
			if (tmp != 2 && tmp % 2 == 0) {
				--tmp;
				continue;
			}
			if (judge_Prime_num(tmp)) {
				++cnt;
			}
			--tmp;
		}
		cout << cnt << endl;
		//clock_t end = clock();
		//cout << cnt << "     " << (double)(end - start) / CLOCKS_PER_SEC << "sec" << endl;
	}
}

C++: #include<bits/stdc++.h>
using namespace std;

#define maxPN 100000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}