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>
#define N 1000000
using namespace std;

int main(){
  int n;
  bool prime[N];
  for(int i=0;i<N;i++) prime[i]=true;
  prime[0]=prime[1]=false;
  for(int i=0;i<N/2;i++){
    if(!prime[i]) continue;
    for(int j=i+i;j<N;j+=i) prime[j]=false;
  }
  while(cin>>n){
    int ans=0;
    for(int i=0;i<=n;i++)
      if(prime[i]) ans++;
    cout<<ans<<endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
bool F(int n)
{
	bool r=true;
	for(int i=2;i<=(n/2);i++)
	{
		if(n%i==0){
			r=false;
			break;
		}
	
	}	
	return r;
}

int main()
{
	int number=0;
	int result=0;
	while(1)
	{
		result=0;
		cin>>number;
		for(int i=number;i>=2;i--)
		{
			if(F(i)==true)
				result++;
		}
		cout << result <<endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a,i;
cin>>a;
for(int x=2x<a;x++){
if(a%x==0){i++}
cout<<i<<endl;
}
return 0;
}

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

#define N 1000000
int main() {
  vector<int> table(N,1);
  table[0]=table[1]=0;
  for (int i=2; i*i<N; i++)
    if (table[i])
      for (int j=i*2; j<N; j+=i)
        table[j] = 0;
  int n;
  while(cin>>n) {
    int ans=0;
    for (int i=2;i<=n;i++) {
      if (table[i]) ans++;
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main( void )
{
	vector <bool> prime( MAX, false );
	prime[2] = true;
	for ( int i = 3; i * i <= MAX; i++ )
	{
		prime[i] = true;
	}

	for ( int i = 3; i <= MAX; i++ )
	{
		if ( prime[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				prime[j] = false;
			}
		}
	}

	while ( !cin.eof() )
	{
		int n;
		cin >> n;
		if ( cin.eof() )
			break;

		int cnt = 1;
		for ( int i = 3; i < n; i += 2 )
		{
			if ( prime[i] ) cnt++;
		}

		cout << cnt << endl;

	}

	return 0;
}

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

std::vector<std::size_t> prime_table = {2};

void make_prime_table(const std::size_t n)
{
    const std::size_t found_last_prime = prime_table.back();
    if(found_last_prime < n)
    {
        std::list<std::size_t> undefined_table;

        for(std::size_t i = found_last_prime + 1; i <= n; ++i)
        {
            undefined_table.push_back(i);
        }

        const std::size_t sn = std::sqrt(n);
        for(std::size_t p = 0; ; ++p)
        {
            for(auto u = undefined_table.begin(); u != undefined_table.end();)
            {
                if(0 == *u % prime_table[p])
                {
                    u = undefined_table.erase(u);
                }
                else
                {
                    ++u;
                }
            }
            if(undefined_table.empty())
            {
                break;
            }
            if(found_last_prime <= prime_table[p])
            {
                prime_table.push_back(undefined_table.front());
                undefined_table.pop_front();
            }
            if(prime_table.back() <= sn)
            {
                break;
            }
        }
        prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
    }
}

std::vector<size_t> prime_acc = {0};

std::size_t prime_size(const std::size_t limit)
{
    if(prime_acc.size() <= limit)
    {
        make_prime_table(limit);
        auto it = prime_table.begin();
        while(prime_acc.size() <= limit)
        {
            it = std::lower_bound(it, prime_table.end(), prime_acc.size());
            if(it != prime_table.end())
            {
                prime_acc.insert(prime_acc.end(), *it - prime_acc.size(), prime_acc.back());
                prime_acc.push_back(prime_acc.back() + 1);
            }
            else
            {
                prime_acc.insert(prime_acc.end(), limit - prime_acc.size() + 1, prime_acc.back());
            }
        }
    }
    return prime_acc[limit];
}

int main()
{
    std::size_t n;

    while(std::cin >> n, !std::cin.eof())
    {
        std::cout << prime_size(n) << std::endl;
    }
}

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

using namespace std;
int main()
{
    bool a[1000000];
    for (int i = 0; i < 1000000; i++) {
        a[i] = true;
    }
    for (int i = 2; i <= sqrt(1000000); i++) {
        if (a[i]){
            for (int j = i; i*j < 1000000; j++) {
                a[i*j] = false;
            }
        }
    }
    
    
    int n;
    while (cin >> n) {
        int cnt = 0;
        for (int i = 2; i <= n; i++) {
            if (a[i]){
                cnt++;
            }
        }
        cout << cnt << endl;
    }
    return 0;
}

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

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

int main(){
  bool p[1000000];
  int num[1000000];
  int c,n;

  for(int i=0;i<1000000;i+=2)p[i] = false;
  for(int i=1;i<1000000;i+=2)p[i] = true;
  p[1] = false;
  p[2] = true;

  c = 3;
  while(c < 1000){
    for(int i=3*c;i<1000000;i+=2*c)p[i] = false;
    do{c+=2;}while(!p[c]);
  }

  c = 0;
  for(int i=0;i<1000000;i++){
    if(p[i])c++;
    num[i] = c;
  }

  while(cin >> n)cout << num[n];
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;

	while(cin >> n){
		int count = 0;
		for(int i=0; i<n+1; i++){
			if(prime(i)){count++;}
		}

		cout << count << endl;
	}
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;

	while(cin >> n){
		int count = 0;
		if(n>2){count++;}
		for(int i=1; i<n+1; i=i+2){
			if(prime(i)){count++;}
		}

		cout << count << endl;
	}
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}
int p[100006];

signed main(){
  loop(i,2,100001){
    if(Is_Prime(i))p[i]=1;
  }
  rep(i,100001)p[i+1]+=p[i];
  int n;
  while(cin>>n){
    cout<<p[n]<<endl;
  }
  return 0;
}