Go: package main

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

func search(min, max int, channel chan int) {
	flag := false
	count := 0
	for i := min; i <= max; i++ { //1を除く入力値以下の数字
		for j := 2; j < i; j++ {
			if i%j == 0 {
				flag = true
				break
			}
		}
		if !flag {
			count++
		} else {
			flag = false
		}
	}
	channel <- count
	return
}

func main() {
	count := 0
	channel := make(chan int)
	scanner := bufio.NewScanner(os.Stdin)
	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		for i := 2; i < num; i += 10 {
			if i+10 < num {
				count++
				go search(i, i+10, channel)
			} else {
				count++
				go search(i, num, channel)
			}
		}
		var ans int
		for i := 0; i < count; i++ {
			ans += <-channel
		}

		fmt.Println(ans)
	}
}

C++: #include<iostream>
#include<string.h>
int main(){bool*v=new bool[500000];int m,n=999999,o,c,d,i,e;memset(v,1,c=n/2+1);for(i=m=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;for(o=m*2+1,d=o*3;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(;!(std::cin>>n).eof();){if(n<3)e=n>1;else{c=(n&1?n:--n)/2+1;e=1;for(i=1;i<c;)e+=v[i++];}printf("%d\n",e);}delete[]v;}

C++: #include <iostream>

#define N 100000

using namespace std;

int main() {
	int n;
	bool p[N];
	for(int i = 0; i <= N; i++) p[i] = 0;
	for(int i = 3; i <= N; i += 2) p[i] = 1;
	p[2] = 1;
	for(int i = 0; i < N; i++){
		if(!p[i]) continue;
		for(int j = 2 * i; j < N; j += i) p[j] = 0;
	}

	while(cin >> n){
		int j = 0;
		for(int i = 0; i <= n; i++){
			if(p[i]) j++;
		}
		cout << j << endl;
	}	
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){

	int a,n,j;
	cin>>a;
	n=0;
	for(int i=2;i<=a;i++){
		for(j=2;j<i;j++){
			if(i%j==0)break;
		}
		if(i == j) n += 1;
	}

	cout<<n<<endl;
}

C++: #include<stdio.h>
#include<math.h>
int gurobal[1000001]={0};
int main(void)
{
	int n=0;
	int i=0,j=0;
	int heihoukon=0;
	int count=0;
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		gurobal[1]=0;
		for (i=2;i<=n;i++)
		{
			gurobal[i]=1;
		}
		(int)heihoukon=sqrt((double)n);
		for (i=2;i<=heihoukon;i++)
		{
			if (gurobal[i]!=0)
			{
				for (j=i*2;j<=n;j+=i)
				{
					gurobal[j]=0;
				}
			}
		}
		for (i=2;i<=n;i++)
		{
			if (gurobal[i]!=0)
			{
				count++;
			}
		}
		printf("%d\n",count);
	}

	return 0;
}

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

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

int count_prime(int n)
{
	int count = 0;
	for (int i=2;i<=n;i++) 
		if (check_prime(i)) 
			count++;

	return count;
}

int main()
{
	int n = 0;
	vector<int> result;

	while(cin >> n) 
		result.push_back(count_prime(n));

	for(int i=0;i<result.size();i++)
		cout << result[i] << endl;

	return 0;
}

C++: #include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>

using namespace std;

int prime[300000],nprime;
int mark[1000002];
int i,j;

int sieve(int n)
{
    int limit=sqrt(n*1.)+2;
    mark[1]=1;
    for(i=4;i<=n;i+=2) mark[i]=1;
    prime[nprime++]=2;
    for(i=3;i<=n;i+=2){
        if(!mark[i]){
            prime[nprime++]=i;
            if(i<=limit){
                for(j=i*i;j<=n;j+=i*2){
                    mark[j]=1;
                }
            }
        }
    }
    printf("%d\n",nprime);
    nprime=0;
}

int main()
{
    int n;
    while(scanf("%d",&n)!=EOF){
        sieve(n);
    }
    return 0;
}

C++: #include <stdio.h>
#include <string>
#include <iostream>

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    
    while(scanf("%d",&n)!=EOF){
        int temp = 0;
        if(n==1){
            printf("%d",0);
        }else{
            for(int i=2; i<=n; i++ ){
                temp+=sosuu(i);
            }
            printf("%d\n",temp);
        }
    }
    
    
}

int sosuu(int n){
    for(int i=2; i<n; i++){
        if(n%i == 0){
            return 0;
        }
        if(i!=2){
            i++;
        }
    }
    return 1;
}

C++: #include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000; 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/2; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

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

int main()
{
	int n;

	while(std::cin >> n)
	{
		int checkLimit = sqrt((double)n);

		std::vector<bool> Prime(n+1,true);

		Prime[0] = false;

		Prime[1] =false;
		
		for(int i=2; i<checkLimit+1; ++i)
		{
			if(!(Prime[i]))
			{
				continue;
			}

			for(int j=2*i; j<n+1; j+=i)
			{
				Prime[j] = false; 
			}

		}

		std::cout << std::count(Prime.begin(),Prime.end(),true) << '\n';
	}
}

C++: #include <iostream>

int prime_number_count(const int n)
{
    int cnt;
    bool was_not_divisible;
    
    if (n < 2){
        return 0;
    }
    
    cnt = 1;
    for (int i = 3; i <= n; i += 2){  // dividend: 被除数
        was_not_divisible = true;
        for (int j = 3; j < i; j += 2){  // divisor: 除数
            if (i % j == 0){
                was_not_divisible = false;
                break;
            }
        }
        if (was_not_divisible){
            cnt++;
        }
    }
    
    return cnt;
}

int main()
{
    int n;
    
    while (std::cin >> n){
        std::cout << prime_number_count(n) << std::endl;
    }
    
    return 0;
}

C++: #include<stdio.h>

int main(void){
  int n;
  while(scanf("%d",&n)!=EOF){
    if(n==1){
      printf("%d\n",0);
      break;
    }
    int p[1000000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    scanf("%d",&n);
	while(1<=n<=999999){
		for(i=2;i<=n;i++){
			z=0;
			for(j=2;j<=i;j++){
				if(i%j==0 && i!=j){
					z++;
					break;
				}
			}
			if(z==0){
				x++;
			}
		}
		printf("%d\n",x);
		scanf("%d",&n);
	}
	return 0;
}

C++: #include <stdio.h>
int isprime(int n){
	int i;
	for(i=2;i<n;i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main(){
	int i,n,c=0;
	scanf("%d",&n);
	for(i=2;i<=n;i++){
		if(isprime(i) == 1){
			c++;
		}
	}
	printf("%d",c);
	return 0;
}

C++: #include <iostream>

#define MAX_N 999999

unsigned long long int n;
bool cache[MAX_N+1];

void make_cache(void)
{
    for (int i = 0; i <= MAX_N; i++) {
        cache[i] = true;
    }

    for (int i = 2; i <= MAX_N; i++) {
        if (cache[i]) {
            for (int j = i + i; j <= MAX_N; j += i) {
                cache[j] = false;
            }
        }
    }
}

void solve(void)
{
    int count = 0;
    for (int i = 2; i <= n; i++) {
        if (cache[i]) count++;
    }
    std::cout << count << std::endl;
}
        

int main(void)
{
    make_cache();
    while (std::cin >> n) {
        if (n == 0) break;
        solve();
    }
    return 0;
}

C++: #include<stdio.h>
#include<math.h>

int main(){
	int ans[1000000];
	int count=2;
	
	for(int i=4;i<1000000;i++){
		bool p=true;
		double sqrti = i;
		for(int j=2;j<=sqrt(sqrti);j++){
			if(i % j == 0){
				p=false;
				break;
			}
		}
		if(p){
			count++;
			ans[i]=count;
			}
		else ans[i]=count;
	}
	ans[1] = 0;
	ans[2] = 1;
	ans[3] = 2;
	
	int n;
	
	while(scanf("%d",&n)==1){
		printf("%d\n",ans[n]);
	}
	return 0;
}