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>
using namespace std;

int main(){
        int n;
        int d; //素数を入れるための添字
        bool count; //割りきれるかどうかの判定
        int number[400000]; //素数を入れておく
        number[0] = 2;
        
        
        while(cin >> n != 0){
                d = 0;
                for(int i = 3; i <= n; i++){
                        count = true;
                        for(int j = 0; j <= d; j++)
                                if(i % number[j] == 0)
                                        count = false;
                        if(count == true){
                                d++;
                                number[d] = i;
                        }
                }
        cout << d+1 << endl;
        }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool prime(int num){
	if(num<2)return false;
	else if(num==2)return true;
	else if(num%2==0)return false;
	double sqrtNum = sqrt((double)num);
	for(int i=3;i<=num;i++){
		if(num%i==0)return false;
	}
	num=0;
	return true;
}
int main(){
	int n,count=0;
	while(cin>>n){
		for(int ii=1;ii<=n;ii++){
		count+=prime(ii);
		}
		cout<<count<<endl;
		count=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int n;
const int MAX=1e6+5;
int pri[MAX];
bool py[MAX];
int c0=0;
void isprime()
{
	memset(py,true,sizeof(py));
	int t=sqrt(MAX);
	pri[0]=pri[1]=false;
	for(int i=2;i<=t;i++)
	{
		if(py[i])
		{
			for(int j=2*i;j<=MAX;j+=i)
			py[j]=false;
		}
	}
	for(int i=2;i<=MAX;i++)
	{
		if(py[i]) pri[c0++]=i;
	}
}
int main()
{
	c0=0;
	isprime();
	while(cin>>n)
	{
		int c=0;
		for(int i=0;i<c0;i++)
		{
			if(pri[i]<=n) {c++;continue;}
			break;
		}
		cout<<c<<endl;
	}
	return 0;
}

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

int main(void){
	int array[30]={ },n;
	for(int* ite=array;cin>>*ite;ite++);
	int max=*(max_element(array,array+30));
	bool* hurui = new bool[max+1];
	fill(hurui,hurui+max+1,true);
	hurui[0]=hurui[1]=false;
	for(int i=2;i<max;i++){
		if(!hurui[i]) continue;
		for(int j=i*2;j<max;j+=i)
			hurui[j]=false;
	}
	for(int* ite=array;*ite;ite++)
		cout << count(hurui+1,hurui+1+(*ite),true) <<endl;
	delete[] hurui;
}

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

using namespace std;

#define MAX_N 99999
#define MAX_D 30

bool prime_check(int n, int k = 2)
{
	if (n < k * k) { return true; }

	if (n % k == 0) { return false; }

	return prime_check(n, k + 1);
}

int main()
{
	int n;

	bool isprime[MAX_N + 1];

	for (int i = 2; i < MAX_N + 1; i++)
	{
		isprime[i] = prime_check(i);
	}

	while (cin >> n)
	{
		cout << count(isprime + 2, isprime + n + 1, true) << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>

using namespace std;
const int maxx = 1000000;
bool is_prime[maxx];
int prime[maxx];
int a,cnt = 0;
int main()
{
    memset(is_prime,true,sizeof is_prime);
    is_prime[0] = is_prime[1] = false;
    for(int i = 2; i * i < maxx; i ++ )
    {
        if(is_prime[i])
        {
            prime[cnt++]=i;
            for(int j = i*2;j < maxx; j+=i ) is_prime[j] = false;
        }
    }
    while(scanf("%d",&a)!=EOF)
    {
        int k = upper_bound(prime,prime+cnt,a) - prime;
        printf("%d\n",k);

    }

    return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(int s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

C++: #include <iostream>
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;
int res;
scanf("%d",&n);
for(int i=2;i<=n;i++){
if(is_prime(n)) res++;
}
printf("%d\n",res);
}

C++: #include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
	int n, count,k;

	while(cin >> n){
		count = 1;
		k = 0;

		for(int i = 3; i <= n; i += 2){
			for(int j = 3; j <= sqrt((double)i); j += 2)
			{
				if(i%j == 0){
					k = 1;
					break;
				}
			}
			if(k == 0){
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
using namespace std;
main(){
	int n,p[100000];
	for(int i=0;i<=100000;++i)p[i]=1;
	p[0]=0;p[1]=0;
	for(int i=2;i<=100000,i*i<100000;++i){
		for(int j=2;j<=100000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
const int len 200000
int prime[len];
int a; 
bool mark[len];

void f()
{
    a=0;
    long long int i,j;
    for( i=0; i<len; i++)
    {
        mark[i]=false;
    }
    for( i=2; i<len; i++)
    {
        if(mark[i]==1)  
            continue;
        else
        {
            prime[a++]=i;
            for( j=i*i; j<len; j+=i)
            {
                mark[j]=true;
            }
        }
    }
}


int main()
{
    f();
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",prime[n-1]);
    }
    return 0;
}

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

bool prime(int a) {
	for (int b = 3;; b += 2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	while (1) {
		int s = 0;
		int a;
		cin >> a;
		if (cin.fail());
		if (a > 1)s++;
		if (a > 2)s++;
		for (int b = 5; b <= a; b+=2) {
			if (prime(b))s++;
		}
		cout << s << endl;
	}
}