Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: #include <iostream>
using namespace std;
const int len = 999999;

int main()
{
    int arr[100] = {0},n,count=0;
     cin>>n;
    for (int i = 2; i < n; i++)
    {
        for (int j = i * i; j < n; j+=i)
        {
            arr[j - 1] = 1;
        }
    }
    for (int i = 1; i < n; i++)
    {

        if ((arr[i - 1] == 0)&&(i>1))
            count++;


    }
    std::cout <<count <<endl;
}

C++: #include<bits/stdc++.h>
#include<iostream>
#define LIM 999999
using namespace std;
long long int i,j,a,odd;
bool prime[LIM];
long long int arr[999999];
void sieve()
{
    
    arr[a++]=2;
    for(i=3;i<=LIM;i+=2)
    {
        if(!prime[i])
        {
            arr[a++]=i;
            if(i*i<=LIM)
            {
                odd=i;
                
                for(j=i*i;j<=LIM;j=i*odd)
                {
                    prime[j]=true;
                    odd+=2;
                }
            }
        }
        if(a==999999)
            break;
    }
}
int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL);
    sieve();
    long long int k, num, count = 0;
    k=0;
    while(scanf("%lld", &num)!=EOF)
    {
        k=0;
        count = 0;

        for(int i=1; i<=num; i++)
        {
            if(i == arr[k])
                {
                    count++;
                    k++;
                }
        }
        printf("%lld\n", count);
    }
    return 0;
}

C++: // 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
#ifdef DAIJOBU
#include "/home/v-o_o-v/deb.h"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#include <bits/stdc++.h>
#define deb(x...)
#endif 

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	vector<int> primes;
	primes.push_back(2);
	for(int i = 3; i <= 999999; i += 2){
		bool ok = true;
		for(int j = 2; j * j <= i; j++){
			if(i % j == 0)ok = false;
		}
		if(ok)primes.push_back(i);
	}
	int n;
	while(cin >> n){
		int ans = 0;
		for(auto i:primes)if(i <= n)ans++;
		cout << ans << '\n';
	}
	return 0;
}
// Write Here

C++: #include<cstdio>
#include<vector>
#include<cmath>
using namespace std;
int main(){
    int n;
    while(scanf("%d",&n)!=-1){
        int ans=0;
        vector<bool> tab(n+1,true);
        int upto=sqrt(n);
        for(int i=2;i<=upto;i++){
            if(tab[i]){
                for(int j=i*2;j<=n;j+=i){
                    tab[j]=false;
                }
            }
        }
        for(int i=2;i<=n;i++){
            if(tab[i]) ans++;
        }
        printf("%d\n",ans);
    }
}

C++: #include <iostream>
using namespace std;
bool prime[999999]={1,1,0,0};
int main(){
  for(int i=2;i<999999;i++){
    if(prime[i]==0) for(int j=i<<1;j<99999;j+=i)
    prime[j]=1;
  }
  int n;
  while(cin>>n){
    int ans=0;
    for(int i=2;i<=n;i++)
      ans+=!prime[i];
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
#define N 1000000

int main()
{
	bool prm[N];
	for(int i=0; i<N; i++)
	{
		prm[i]=true;
         }
		int upto= (int) sqrt(N);
		for(int i=2;i<= upto; i++)
		{
			if(prm[i])
{
				for(int j=2; j*i<N; j++)
				{
				    prm[i*j]=false;
				}
}
		}
		int n;
		while(cin>>n)
		{
			int count=0;
			for(int i=2; i<=n; i++)
			{
				if(prm[i])
					count++;
			}
			cout<<count<<endl;
		}
	}
	return 0;
}

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

using namespace std ;

int n, cnt[1000008]; 
bool prime[1000008];

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

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

int main(){

  int n,i,j,ans;


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

    for(;n > 1 ; n--){
      if(n == 2 ) ans++;
      for(i = 2 ; i <= (int)sqrt((double)n) ; i++){
	if(n%i == 0){
	  break; 
	}
      }
      if(n%i != 0) ans++;
    }
    cout << ans << endl;

  }
  return 0;
}

C++: #include <iostream>

int prime_numbers[999999];
int cur_index = 4;

bool is_prime(int p) 
{
    for (int i = 0; i < cur_index; i++) {
        if (p % prime_numbers[i] == 0) {
            return false;
        }
    }
    return true;
}

int main(void)
{
    prime_numbers[0] = 2;
    prime_numbers[1] = 3;
    prime_numbers[2] = 5;
    prime_numbers[3] = 7;

    int n;
    std::cin >> n;

    for (int i = 8; i <= n; i++) {
        if (is_prime(i)) {
            prime_numbers[cur_index] = i;
            cur_index++;
        }
    }

    std::cout << cur_index << std::endl;
//    for (int i = 0; i < cur_index; i++) {
//        std::cout << prime_numbers[i] << std::endl;
//    }
}

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

int main(void){
  int n;
  int p[1000000];
  p[0] = p[1] = 0;
  p[2] = 1;
  int ans = 0;
  for(int i = 3; i <= 1000000; i += 2){
    bool flag = true;
    for(int j = 3; j <= sqrt(i); j += 2){
      if(i % j == 0){
	flag = false;
      }
    }
    if(flag)
      ans++;
    p[i] = ans;
  }
  while(cin >> n){
    cout << p[n] << endl;
  }
  return 0;
}

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

	bool is_prime[1000000];
	int n_prime[1000000];
int main()
{
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2; i<1000000; i++){
		is_prime[i]=true;
	}
	
	for(int i=2; i*i<1000000; i++){
		if(is_prime[i]){
			for(int j=i*i; j<1000000; j+=i){
				is_prime[j]=false;
			}
		}
	}


	int cnt=0;
	for(int i=0; i<1000000; i++){
		if(is_prime[i]){
			cnt++;
		}
		n_prime[i]=cnt;
	}
	cout<<"finish"<<endl;
	while(true){
		int n;
		cin>>n;

		if(cin.eof())
			break;
	
		cout<<n_prime[n]<<endl;
	}
	
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	while (cin)
	{
		int tmp;

		cin >> tmp;

		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;

		//if (cin.eof()) { break; }
	}

	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
 
using namespace std;
 
int p[1000000];
int cnt[1000000];
 
int main()
{
  fill(p, p + 1000000, 1);
  p[0] = p[1] = 0;
  for(int i=2;i<1000000;i++)
    for(int j=i*2;j<1000000;j+=i)
      p[j] = 0;
 
  for(int i=1;i<1000000;i++)
    cnt[i] = cnt[i-1] + p[i];
 
  int n;
  while(scanf("%d", &n) != -1)
    printf("%d\n", cnt[n]);
 
  return 0;
}

C++: #include <stdio.h>
int main(){ 
	const int MAX_V=999999;
	int prime[MAX_V+1];
	int i,k,v,n,sum[MAX_V+1];
	prime[0]=0;
	prime[1]=0;
	for(i=2;i<=MAX_V;i++){
		prime[i]=1;
	}
	for(i=2;i*i<=MAX_V;i++){
		if(prime[i]){
			for(k=2*i;k<=MAX_V;k+=i){ 
				prime[k]=0;
			}
		}
	}
	sum[0]=0;
	for(i=0;i<=MAX_V;i++){ 
		sum[i+1]=sum[i]+prime[i]; 
	}
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",sum[n+1]);
	}
	return 0; 
}