Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

C++: #include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
#include <cmath>

int main(void);
int count_prime_number(int n);

int main(){
	int n;
	int cnt = 0;
	int result[30];

	//while (cnt < 3){
		//std::cin >> n;
	while (std::cin >> n){
		//result[cnt] = count_prime_number(n);
		cnt++;
	}

	for (int i = 0; i < cnt; i++){
		std::cout << result[i] << std::endl;
	}

	//while (1);
	return 0;
}


//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
	int rtn = 0;

	//2だけ個別チェック
	if (n >= 2){
		rtn++;
	}

	for (int i = 3; i <= n; i+= 2)
	{
		bool is_prime_num = true;
		for (int j = 3; j <= sqrt(i); j+= 2)		//ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
		{
			if (i % j == 0)
			{
				is_prime_num = false;
				break;
			}
		}

		if (is_prime_num){
			rtn++;

			//デバッグ
			//std::cout << i << std::endl;
		}
	}

	return rtn;
}

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

int main(){
  
  int n;

  while(cin >> n){
    bool Prime[1000000] = {};
    int i,j,count;
    count = n;
    for(i = 2; i <= sqrt(n) ; i++){
      if(Prime[i] == false){        
	for(j = 2; i*j <= n ; j++){
	  if(!Prime[i*j]){
	    Prime[i*j] = true;
	    count--;
	  }
	}
      }
    }
    cout << count-1 << endl;
  }
  return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int prime(int n)
{
    int a,b;
    if(n==(0||1)) return 0;
    else if (n==2) return 1;
    else if(n%2==0) return 0;
    a=sqrt(n);
    for(b=3;b<=a;b+=2)
    {
        if(n%b==0) return 0;
    }
return 1;
}
int main()
{
    int n,i,j,k;
    for(k=1;k<=30;k++)
    {
        cin>>n;
        j=0;
        for(i=1;i<=n;i++)
        {
            if(prime(i)==1) j++;
        }
    cout<<j<<endl;
    }
}

C++: #include <iostream>
using namespace std;
const int maxn=1e6 + 10;
int p[maxn],inp[maxn],f[maxn],top;
void init(){
	for(int i=2;i<maxn;i++){
		if(!inp[i]){
			p[top++]=i;
		}
		for(int j=0;j<top && i*p[j]<maxn;j++){
			inp[i*p[j]]=1;
			if(!(i%p[j]))
				break;
		}
		f[i]=f[i-1]+1-inp[i];
	}
}
int main(){
	init();
	int n;
	while(cin>>n){
		cout<<f[n]<<endl;
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
	int i,j,n;
	bool judge[1000000]={0};
	
	for(i=3; i<1000000; i++)if(i % 2 == 0)judge[i] = 1;
	
	for(i=3; i<500000; i+=2){
		if(judge[i]==0){
			for(j=i*2;j<1000000;j+=i){
				if(j % i == 0){
					judge[j]=1;
				}
			}
		}
	}
	
	while(scanf("%d",&n) != EOF){
		int count=0;
		for(i=2;i<=n;i++){
			if(judge[i]==0)count++;
		}
		printf("%d\n",count);
	}
	return 0;
}

C++: #include<stdio.h>
#include<iostream>
#include<math.h>
#include<chrono>
#include<string>
#include<fstream>
#include<vector>

using namespace std;



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

int main() {

	int num;
	while (cin >> num) {
		int count = 0;
		for (int i = 2; i <= num; i++) {
			if (isPrime(i))count++;
		}
		cout << count << endl;
	}


	
	//std::system("pause");
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <set>
#include <functional>

class Mod{
		const int n;
		public:
			Mod(int const _n):n(_n){}
			bool operator()(const int _src)const{
				return ! (_src % n);
			}
	};

const std::vector<int> Eratosthenes(const std::vector<int> src){
	std::vector<int> result,tmp(src);
	while(!tmp.empty()){
		int n(tmp[0]);
		result.push_back(n);
		Mod mod(n);
		std::vector<int>::iterator it= std::remove_if( tmp.begin(), tmp.end(), mod );
		tmp.erase(it,tmp.end());
	}
	return result;
}

static int const MAX(1000000);

int main(int,char**){
	std::vector<int> vec;
	vec.reserve(MAX);
	for(int i(2);i<=MAX;++i) vec.push_back(i);
	std::vector<int> const primes= Eratosthenes(vec);
	int n;
	while(std::cin >>n){
		std::vector<int>::const_iterator it =  std::upper_bound(primes.begin(),primes.end(),n);
		std::cout << it-primes.begin() <<std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(long long int j = (long long int)i*(long long int)i;j<MAX;j=j*j){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include <iostream>

using namespace std;

int main(void)
{
	int n;
	int pnum;
	
	while (cin >> n){
		int ct  = 0;
		for (int i = 2; i <= n; i++){
			for (pnum = 2; pnum <= n; pnum++){
				if (i % pnum == 0){
					break;
				}
			}
			if (i == pnum){
				ct++;
			}
		}
		cout << ct << endl;
	}
	
	return (0);
}

C++: #include<iostream>

#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)


using namespace std;



int main(){
	bool prime[1000001];
	rep(i, 1000001){
		prime[i] = true;
	}
	prime[0] = prime[1] = false;
	
	loop(i, 2, 1001){
		if (prime[i]){
			for (int j = i * 2; j < 1000001; j += i){
				prime[j] = false;
			}
		}
	}



	int ord;
	while (cin >> ord){
		int cnt=0;
		rep(i, ord + 1){
			if (prime[i]){
				cnt++;
			}
		}
		cout << cnt << endl;
		cnt = 0;
	}


}

C++: #include <stdio.h>

int main(){
	int sosuu[] = { 2, 3, 5 }, i, x, y = 3,n=0,z,d=0;
	while (scanf("%d", &n) != EOF){
		z = 0;
		if(d < n)
		{for (i = 3; i < n; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++; d = i; }
			}
		}
	}
		for (i = 0; i < n; i++){ if (sosuu[i] > n + 1)break; z++; }printf("%d\n", z);
	}
	return 0;
}

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

int main(){
	bool *map;
	string str;
	int n, cnt;

	while(1){
		cnt = 0;
		getline( cin, str );
		if( str.size()==0 )	break;
		sscanf(str.c_str(), "%d", &n);
		map = new bool[n+1];
		for( int i=2; i<=n; i++ ){
			map[i] = true;
		}

		for( int i=2; i<=n/2; i++ ){
			for( int j=2*i; j<=n; j+=i ){
				if( map[j] ){
					map[j] = false;
				}
			}
		}

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

C++: #include <iostream>
#include <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

int main(){
  int n;
  while (std::cin >> n) {
    int count=0;//素数の数
    for(int i=2;i<=n;i++){
      if(i==2){
        count++;
        continue;
      }
      int flag=0;
      for(int j=2;j<=sqrt(i);j++){
        if(i%j==0){
          flag=1;
        }
      }
      if(flag==0){
        count++;
      }
    }
    std::cout << count << '\n';
  }

}