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 <stdio.h>
#include <math.h>

int is_prime (int N)
{
    if (N<2) return 0;

    int limit = (int) sqrt(N);
    for (int i=2; i<=limit; ++i)
    {
        if (N%i==0)
            return 0;
    }

    return 1;
}

int main ()
{
    int num, primes, t=0;

    while ((scanf("%d", &num) != EOF) && (t<=30))
    {
        ++t;
        primes = 0;

        for (int i=1; i<=num; ++i)
        {
            if (is_prime(i)) ++primes;
        }

        printf("%d\n", primes);
    }

    return 0;
}

C++: #include<iostream>
#include<string.h>
using namespace std;
int n,ans;
bool a[10005];
int main(){
	while(cin>>n){
		memset(a,true,sizeof(a));
		a[0]=false;
		a[1]=false;
		ans=0;
		for(int i=2;i<=n;i++){
			if(a[i])
				for(int j=2*i;j<=n;j+=i)
					a[j]=false;
		}
		for(int i=1;i<=n;i++)
			if(a[i]) ans++; 
		cout<<ans<<endl;
	}
}

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>

using namespace std;

int main()
{
	int N[3]; int C[3] = { 0, 0, 0 };

	int PRIME[168];

	int cnt = 1;

	PRIME[0] = 2;

	for (int i = 3; i <= 999; i++)
	{
		for (int j = 2; j <= (i - 1); j++)
		{
			if (i % j == 0)
			{
				goto Exit1;
			}
		}
		
		PRIME[cnt] = i; cnt++;

	Exit1:;
	}

	cin >> N[0] >> N[1] >> N[2];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 2; j <= N[i]; j++)
		{
			for (int k = 0; k <= 167; k++)
			{
				if (j % PRIME[k] == 0 && j != PRIME[k])
				{
					goto Exit2;
				}
			}

			C[i]++;

		Exit2:;
		}
	}

	cout << C[0] << '\n' << C[1] << '\n' << C[2] << '\n';

	return 0;
}

C++: #include <bitset> // compact STL for Sieve, better than vector<bool>!
#include <vector>
#include <cstdio>
#include <iostream>
#define ll long long 
#define vi vector<int>

using namespace std;

ll _sieve_size; 
bitset<10000010> bs; 
vi primes; 
void sieve(ll upperbound) { 
_sieve_size = upperbound + 1; 
bs.set(); 
bs[0] = bs[1] = 0; 
for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
primes.push_back((int)i);
} } 
bool isPrime(ll N) { 
if (N <= _sieve_size) return bs[N]; 
for (int i = 0; i < (int)primes.size(); i++)
if (N % primes[i] == 0) return false;
return true; 
} 

int tc,a;
int TestCase,x;

int main()
{
	sieve(1000100); 
	while(scanf("%d",&tc)!=EOF)
    {
        x=0;
        while(tc >= primes[x])
        {
            x++;
        }
        printf("%d\n",x);
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}

int main()
{
	
//	cut here before submit 
//	freopen("testcase.prime", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	vector <int> prime(n+1, 0);

	int i;
	int count = 0;
	for (i = 2; i <= n; ++i){
		if (isprime(i)){
			++count;
		} // end if
		prime[i] = count;
	} // end for

	cout << prime[n] << endl; 

	return 0;
}

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

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;

	while ( scanf("%d" , &num) != EOF ){	
		p[0] = false;
		p[1] = false;
		for (int i=2 ; i<=MAX ; i++){
			p[i] = true;
		}
		answer = 0;

		for (int i=2 ; i<=sqrt(MAX)+1 ; i++){
			if (p[i]==1){
				for (int j=i*2; j<=MAX; j=j+i){
					p[j] = false;
				}
			}
		}

		for (int i=0; i<=num; i++){
			if (p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
	return 0;
}

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

int prime[1000010];
bool is_prime[1000010];
int n;
int main()
{
	while(cin>>n)
	{
		int p = 0;
		for(int i = 0;i <= n;i++)
		{
			is_prime[i] = true;    //先默认全不是素数 
		}
		is_prime[0] = is_prime[1] = false;
		for(int i = 2;i <= n;i++)
		{
			if(is_prime[i])
			{
				prime[p++] = i;
				for(int j = 2 * i;j <= n;j = j + i)
				{
					is_prime[j] = false;
				}
			}
		}
		cout<<p<<endl;
	}
}

C++: #include <iostream>
using namespace std;
??
#define Max 1000000
??
int prime [10000000];
??
int main()
{
????????int n, out;
??
????????for (int i = 2; i * i < Max; i++){
????????????????if (prime[i] == 0){
????????????????????????for (int j = i; j < Max; j += i){
????????????????????????????????if (!(j == i)) prime[j] = 1;
????????????????????????}
????????????????}
????????}
??
????????while (cin >> n){
????????????????out = 0;
????????????????for (int i = 0; i <= n; i++){
????????????????????????if (prime[i] == 0) out++;
????????????????}
????????????????cout << out - 2 << endl;
????????}
????????return(0);
}

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

bool IsPrime(int n){

    if(n % 2 == 0)
        return false;
 
    for(int i = 3; i * i <= n; i += 2)
         if(n % i == 0)
            return false;
    return true;
}
int CheckNum(int input){
	int count = 1;

	for(int i = 2; i < input; ++i){

		if(IsPrime(i)) ++count;
	}
	return count;
}
int main() {
	int input;

	cout << CheckNum(input) << endl;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int x)
{
	if (x < 2)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	for (int i = 3; i <= (int)sqrt(x); i+=2)
		if (x%i == 0)
			return false;
	return true;
}
int main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (cin.fail())
			break;
		int count = 0;
		for (int i = 1; i <= n; i++)
			if (isPrime(i))
				count++;
		cout << count << endl;
	}
}

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

using namespace std;

bool isprime(int n) {
	if (n < 2)
		return false;
	int lim = (int)sqrt((double)n);
	for (int i = 2; i <= lim; i++)
		if (!(n%i))
			return false;
	return true;
}

int main(void) {
	int n, total = 0;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		if (isprime(i))
			total++;
	}
	cout << total << endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

vector<int> makePrimes(int n) { 
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    for(int p=2;p<sqrt(n)+2;p++) if (pr[p]) for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    for(int p=2;p<n + 1;p++) if (pr[p]) res.push_back(p);
    return res;
}

int main(){
	int a;
	while(scanf("%d",&a)!=EOF){
		cout << makePrimes(a).size() << endl;
	}
}