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 <stdio.h>
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
int pcount[MAX_V+1];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

C++: #include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdio>
#include <string>
#include <sstream>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repn(i, n) for(int i = 1; i <= (int)n; ++i)
#define pb push_back
#define lb lower_bound
#define mp make_pair
#define ite iterator
#define max2(x, y) ((x) > (y)) ? (x) : (y)
#define max3(x,y,z) max2((x), max2((y),(z)))
#define max4(v,w,x,y) max2(max2((v),(w)), max2((x),(y)))
#define min2(x, y) ((x) > (y)) ? (y) : (x)
#define min3(x,y,z) min2((x), min2((y),(z)))
#define min4(v,w,x,y) min2(min2((v),(w)), min2((x),(y)))
#define ul unsigned long
#define ull unsigned long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

template<typename T>
bool elem(set<T> st, T val){
	return (st.find(val) != st.end());
}

template<typename T>
void printv(vector<T> vt){
    rep(i, vt.size() - 1)
        cout << vt[i] << " ";
    cout << vt[vt.size() - 1] << endl;
}

typedef vector<int> vint;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef pair<int, int> pii;


vector<int> p;
int main(void){
    p.pb(2);
    for(int i = 3; i <1000000; i += 2){
        int j;
        for(j = 0; p[j] * p[j] <= i; ++j){
            if(i % p[j] == 0) break;
        }
        if(i % p[j] > 0) p.pb(i);
    }
    int n;
    while(cin >> n){
        if(n == 1){
            cout << 0 << endl;
            continue;
        }
        int l = 0, r = p.size();
        while(l + 1 != r){
            int t = (l + r)/2;
            if(p[t] <= n) l = t;
            else r = t;
        }
        int ret;
        if(n < p[r]) ret = r;
        else ret = l;
        cout << ret << endl;
    }
    return 0;
}

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

int main() {
  int N = 1000000;
  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 x;
  while(cin >> x) {
    int ans = 0;
    for (int i = 2; i <= x; i++) {
      if (table[i])
        ans++;
    }
    cout << ans << endl;
  }
}

C++: #include <iostream>
#include <math.h>
#define MAX 1000010
using namespace std;

int main(){
	int n;
	int *prime,i,j;
	prime = new int[80000];
	int *answer = new int[MAX];
	int count;
	bool flag;

	count = 1;
	answer[0] = 0;
	answer[1] = 0;
	answer[2] = 1;
	for(i = 3; i <= 1000000; i+=2){
		flag = true;
		for(j = 0; j < count; j++){
			if(i % prime[j] == 0){
				flag = false;
				break;
			}
			if(prime[j] * prime[j] > i) break;
		}
		if(flag == true){
			prime[count++] = i;
		}
		answer[i] = count;
		answer[i+1] = count;
	}
	while((cin >> n)!= NULL){
		cout << answer[n] << endl;
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<iostream>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>
#include<cmath>
#define inf 0x3f3f3f3f
using namespace std;

typedef long long ll;
typedef pair<int,int> P;

int prime[1000010];
bool IsPrime[1000010];


void init() {
	memset(prime,inf,sizeof(prime));
	memset(IsPrime,true,sizeof(IsPrime));
	int num=0;
	for(int i=2; i<999999; i++) {
		if(IsPrime[i]) {
			prime[num++]=i;
			if(i<=sqrt(999999)) {
				for(int j=i*i; j<999999; j=j+i) {
					IsPrime[j]=false;
				}
			}
		}
	}
}
int main() {

	int x;
	init();
	while(scanf("%d",&x)!=EOF) {
		printf("%d\n",upper_bound(prime,prime+999999,x)-prime);
	}

	return 0;
}

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

using namespace std;

vector<int> PrimeNumber;
int p = 0;

int f(int x){
	if (x == 2) {
		PrimeNumber.push_back(x);
		return 1;
	}
	for (int i = 0; i < PrimeNumber.size(); i++){
		if (x%PrimeNumber[i] == 0) return 0;
	}
	PrimeNumber.push_back(x);
	return 1;
}

int main(){
	long int n;
	int ans = 0;
	while (1){
		cin >> n;
		ans = 0;
		PrimeNumber.clear();
		for (int i = 2; i <= n; i++){
			ans += f(i);
		}
		cout << ans << endl;
	}
}

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

int main() {
  bool check_prime[1000000] = {false};
  int n;

  for (int i=2; i < 1000; i++) {
    if (!check_prime[i]) {
      for (int j = i*i; j < 1000000; j+=i) {
        check_prime[j] = true;
      }
    }
  }

  while (cin >> n) {
    int answer = 0;
    for (int i = 2; i <= n; i++) {
      if (!check_prime[i]) { 
        answer++;
      }
    }
    cout << answer << endl;
  }

  return 0;
}

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

int main(){
	int NUM;
	std::list<int> numList,primeList;
	std::cin >> NUM;
	if(NUM<2){
		return 0;
	}
	for(int i=2;i<=NUM;++i){
		numList.push_back(i);
	}
	
	for(int i=numList.front();i<std::sqrt(NUM);i=numList.front()){
		primeList.push_back(i);
		numList.erase(std::remove_if(numList.begin(),numList.end(),[&](int num){return num%i==0;}),numList.end());
	}
	std::copy(numList.begin(),numList.end(),std::back_inserter(primeList));

	std::cout << primeList.size() << std::endl;

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

int main(){

	int i,j,k,n,x;

	while(std::cin >> n){
		x = 1;
		for(i=3;i<=n;i+=2){
			k = 0;
			for(j=3;j<i;j+=2){
				if(i%j == 0){
					k = 1;
					break;
				}
			}
			if(k == 0){
				x++;
			}			
		}
		std::cout << x << std::endl;
	}
}