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++: #define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    //ios::sync_with_stdio(false);
    //cin.tie(0);

    vector<int> nl;
    int mx = 0;
    do{
        int n;
        cin >> n;
        if (!cin.eof()){
            nl.push_back(n);
            mx = max(mx, n);
        }else{
            break;
        }
    }while(1);

    double r = sqrt(mx);

    list<int> sl;
    vector<int> primes;

    for (int i = 2; i <= mx; i++) {
        sl.push_back(i);
    }

    while (sl.front() <= r) {
        int p = sl.front();
        primes.push_back(p);
        sl.pop_front();

        auto i = sl.begin();
        while(i != sl.end()){
            if(*i % p == 0){
                i = sl.erase(i);
            }
            else {
                i++;
            }
        }
    }

    for (auto&& i : sl) {
        primes.push_back(i);
    }

    for (auto&& n : nl) {
        auto p = upper_bound(primes.begin(), primes.end(), n);
        cout << p - primes.begin() << endl;
    }

    return 0;
}

C++: #include <stdio.h>
int main(void){
	int k,j,a;
	char flag[1000000]={1,1};//0,1は除外する
	for(k=2;k<1000;k++){
		if(flag[k]==0){
			for(j=k*k;j<1000000;j+=k)
				flag[j]=1;
		}
	}
	while(~scanf("%d",&a)){
		k=0;
		for(j=0;j<a;j++) if(flag[j]==0) k++;
		printf("%d\n",k);
	}
}

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

int main()
{
	int n[30];
	int i=0;
	while(cin >> n[i]) {i++;}
		
	for (int k=0;k=i;k++){
		int s=1;
		for (int j=3;j<=n[k];j++){
			for(int m=2;m<j;m++){
				if(j%m==0){break;}
				if(m==j-1){s=s+1;}
			}
		}
		cout << s << endl;
	}	
    return 0;
}

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

int main(){
  bool is_prime[1000000];

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

  for(int i=2; i*i<1000000; i++){
    if(is_prime[i]){
      for(int j=i*i; j<1000000; j+=i){
	is_prime[j] = false;
      }
    }
  }

  int n_prime[1000000];

  int cnt = 0;
  for(int i=0; i<1000000; i++){
    if(is_prime[i]){
      cnt++;
    }

    n_prime[i] = cnt;
  }

  while(true){
    int n;
    cin >> n;

    if(cin.eof())
      break;

    cout << n_prime[n] << endl;
  }

  return 0;
}

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

using namespace std;


int main(int argc, const char * argv[]) {
    // insert code here...
    
    int maxNumber;
    int countPrime=0;
    bool judgePrime = true;
    
    cin >> maxNumber;
    
    for(int i=2; i<=maxNumber;i++){
        for(int j=2; j<i;j++){
            if(i%j==0){
                judgePrime = false;
            }
        }
        if(judgePrime){countPrime++;}
        judgePrime = true;
    }
    cout << countPrime;
    
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
bool prime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
    int c,i,p=0;
    int in[30],out[30];
    while(scanf("%d",&in[p])!=EOF)
    {
        c=0;
        for(i=2;i<=in[p];i++)
        {
            if(prime(i))
                c++;
        }
        out[p] = c;
        p++;
    }
    for(i=0;i<p;i++)
        cout<<out[i]<<endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
int main() {
	int a;
	int sum;
	while (cin >> a){
		sum = 0;
		for (int i = 0; i < a; i++){
			int y = 0;
			int l = i + 1;
			for (int i = 1; i != l+1; i++){
				if (l % i == 0) {
					y++;
				}
			}
			if (y == 2)sum++;
		}
		cout << sum << endl;
	}
}

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

int main(){
	const int MAX_n = 1000000;
	int n;
	bool prime[MAX_n];
	int res;
	
	for(int i = 0; i < MAX_n; i++) prime[i] = false;
	
	for(int i = 2; i < MAX_n; i++){
		if(!prime[i]){
			//printf("%d\n", i);
			for(int j = i + i; j < MAX_n; j += i){
				prime[j] = true;
				
			}
		}
	}
	
	//for(int i = 0; i < MAX_n; i++) if(prime[i]) printf("%d\n", i);
	
	while((scanf("%d", &n)) != EOF){
		res = 0;
		
		for(int i = 2; i <= n; i++){
			if(!prime[i]){ res++; }
		}
		
		printf("%d\n", res);
	}
	
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
 
#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
 
typedef long long ll;
typedef pair<int, int> ii;

int main(){

	vector<bool> used(1000000);
	set<ll> prime;
	
	REP(i, 2, 1000000){
		if(!used[i]) prime.insert(i);
		for(int j = 1; i * j < 1000000; j++){
			used[i*j] = true;
		}
	}
	
	int n;
	while(cin >> n){
		auto it = upper_bound(prime.begin(), prime.end(), n);
		cout << distance(prime.begin(), it) << endl;
	}
	
	
	return 0;
}

C++: <?php
$max=1000000;
$maxR=floor(sqrt($max));

$ch=[0,0,1,1];

for($i=4;$i<$max;$i+=2){
  $ch[]=0;$ch[]=1;
}

for($i=3;$i<$maxR;$i+=2){
  if($ch[$i]){
    for($j=$i+$i;$j<$max;$j+=$i){
      $ch[$j]=0;
    }
  }
}

for($i=3;$i<$max;$i++){
  $ch[$i]+=$ch[$i-1];
}

while(fscanf(STDIN,"%d",$n)){
  printf("%d\n",$ch[$n]);
}

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

using namespace std;

bool isPrimes[1000000];

int main()
{
	int res = 0;
	int n;
	scanf("%d", &n);
	for (int i = 0; i <= n; ++i)
		isPrimes[i] = true;
	isPrimes[0] = isPrimes[1] = false;
	for (int i = 2; i <= n; ++i)
	{
		if (isPrimes[i])
		{
			for (int j = i*2; j <= n; j += i)
				isPrimes[j] = false;
			++res;
		}
	}
	printf("%d\n", res);

	return 0;
}

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

using namespace std;
const int maxx = 2000000;
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>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

void sieve(int n, vector<int> &primes)
{
    vector<bool> v(n + 1, true);

    // check
    for (int i = 2, end = sqrt(n); i <= end; i++) {
        if (!v[i] || !(i & 1))
            continue;
        for (int j = i + i; j <= n; j += i)
            v[j] = false;
    }

    primes.push_back(2);
    for (int i = 3; i <= n; i += 2)
         if (v[i])
            primes.push_back(i);
}

int main()
{
    vector<int> primes;
    vector<int> inputs;
    int i;

    // read all inputs
    for (int x; cin >> x;)
        inputs.push_back(x);

    // init sieve
    sieve(*max_element(inputs.begin(), inputs.end()), primes);

    for (auto x : inputs) {
        for (i = 0; i < primes.size(); i++) // find
            if (primes[i] == x) {
                i++;
                break;
            } else if (primes[i] > x)
                break;
        cout << i << endl;
    }

    return 0;
}