Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

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

C++: #include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];void k();using namespace std;main(){int n;p[0]=2;m[1]=0;m[2]=1;k();while(cin>>n){cout<<m[n]<<endl;}}void k(){int i,j,e=1;for(i=3;i<N;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}

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

int main()
{
	int n;
	const int MAX = 1000000;
	int primecount[MAX];

	for (int i = 2; i < MAX; i++) {
		primecount[i] = 1;
	}

	for (int i = 2; i < MAX; i++) {
		if (primecount[i] == 1) {
			for (int j = i * 2; i < MAX; j += i) {
				primecount[j] = 0;
			}
		}
	}

	for (int i = 1; i < MAX; i++) {
		primecount[i] += primecount[i - 1];
	}

	short i = 1;

	while (cin >> n || i <= 30) {
		cout << primecount[n] << endl;
		i++;
	}

	return 0;
}

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

using namespace std;

int main()
{
    int n;
    int prime[100000];
    int ptr = 0;

    prime[ptr++] = 2;
    prime[ptr++] = 3;

    while (cin >> n) {
        if (n == 2) {
            cout << "1\n";
            continue;
        }
        else if (n == 3) {
            cout << "2\n";
            continue;
        }

        int count = 2;        
        for (int i = 5; i <= n; i += 2) {
            bool flag = false;
            for (int j = 1; prime[j] * prime[j] <= i; j++) {
                if (!(i % prime[j])) {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                prime[ptr++] = i;
                count++;
            }
        }
        cout << count << "\n";
    }
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
  int n;
  int i,j,c,p;

  while(cin>>n){
    c=1;
    for(i=3;i<=n;i+=2){
      p=0;
      for(j=2;j*j<=i;j+=2){
	if(n%i==0){
	  p=1;
	  break;
	}
      }
      if(p==0){
	c++;
      }
    }
    cout<<c<<endl;
  }
  return 0;
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){

		count=n;
		
		for(i=0;i*i<=n;i++){
			if(c[i]==1){
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]==0;
						count--;
					}
				}
			}
		}

		printf("%d",count);


	}





	return 0;
}

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

using namespace std;

int get_numprime( int num );

int main(void)
{
	int num;

	while(1)
	{
		cin >> num;
		if( cin.eof() ) break;
		cout << get_numprime( num ) << endl;
	}

	return 0;
}

int get_numprime( int num )
{
	int numprime = 1; // 2はすでにカウント

	for( int i = 3 ; i <= num ; i+=2 )
	{
		int flag = 1;
		for( int j = 2 ; j <= sqrt((double)i) ; j++ )
		{
			if( i%j == 0 )
			{
				flag = 0;
				break;
			}
		}
		if( flag == 1 ) numprime++;
	}

	return numprime;
}

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 <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;


while(~scanf("%d",&n)){
int* table =  new int[n+1];
fill((int*)table,(int*)table+sizeof(table),1);
table[0]=0;

for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}

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

bool IsPrime(int n) {
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

int main(void){
	int count = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int p;
		cin >> p;
		if(IsPrime(p)){
			count++;
		}
	}
	count << count << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<500000; i++){
		if(!num[i]){
			for(int j=i*2; j<1000000; j+=i){num[j] = true;}
		}
	}
	int n;
	while(cin >>n){
		int f = 0;
		for(int i=2; i<=n; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

vector<int> eratosthenes(int N)
{
	vector<int> res;
	vector<bool> prime(N + 1, 1);
	prime[0] = prime[1] = false;
	for (int i = 2; i * i <= N; ++i)
	{
		if (prime[i] == true)
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				prime[j] = false;
			}
		}
	}
	for (int i = 0; i <= N; ++i)
	{
		if (prime[i] == true)
			res.push_back(i);
	}
	return res;
}

int main()
{
	auto prime = eratosthenes(1000001);

	int N;
	while (cin >> N)
	{
		int index = 0;
		while (index < prime.size() && prime[index] <= N)
			index++;
		cout << index << endl;
	}
}

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

int CheckNum(int input){
	int count = 0;

	for(int i = 2; i < input; ++i){
		for(int j = 2; j < i + 1; ++j){
			if( i % j == 0){
				if(!(i == j)) break;
				++count;
			}
		}
	}
	return count;
}

int main () {
	int input;

	cin >> input;
	cout << CheckNum(input) << '\n';

	return 0;
}

C++: #include <stdio.h>
int main(){
    bool prime[1000000];
    int n,ans;
    prime[2]=true;
    for(int i=3;i<1000000;i+=2)prime[i]=true;
    for(int i=3;i<=1000;i+=2){
        if(prime[i]){
            for(int j=i*i;j<1000000;j+=i)
                prime[j]=false;
        }
    }
    while(scanf("%d",&n)!=EOF){
        ans=0;
        if(n<3){printf("%d\n",n-1);
            continue;}
    for(int i=3;i<=n;i+=2)if(prime[i])ans++;
        printf("%d\n",ans);
    }
}