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 <vector>
#include <algorithm>
#include <string.h>
using namespace std;

const int MAX_N = 1000000;

vector<int> init(void){
    vector<int> prime;
    bool is_prime[MAX_N];
    memset(is_prime, true, MAX_N);
    
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<MAX_N; i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i; j<MAX_N; j+=i) is_prime[j] = false;
        }
    }
    return prime;
}

int main(int argc, const char * argv[])
{
    int n;
    vector<int> prime = init();
    while(cin>>n){
        cout << upper_bound(prime.begin(), prime.end(), n)-prime.begin() << endl;
    }
    return 0;
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int prime_num[1000001];
    memset(prime_num, 0, 1000001);
    prime_num[2] = 1;
    int ans = 1;
    for(int i = 3; i <= 1000000; i++) {
        if(i % 2 == 0) { 
            prime_num[i] = prime_num[i-1];
            continue;
        }
        bool is_prime = true;
        for(int j = 3; j*j <= i; j++) {
            if(i % j == 0) {
                is_prime = false;
                break;
            }
        }
        if(is_prime) {
            prime_num[i] = prime_num[i-1] + 1;
        } else {
            prime_num[i] = prime_num[i-1];
        }
    }
    int n;
    while(cin >> n) {
        cout << prime_num[n] << endl;
    }
    return 0;
}

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

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		if(!c[i]){
		for(int j = i;i*j < 1000000;j++){
			c[i*j] = true;
		}
		}
		t[i]=t[i-1]+!c[i];
	}
	for(int n;cin>>n;n++){
		cout << t[n] << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

const int MAXN = 1000000;

int tot; bool vis[MAXN];
int prime[MAXN];

void init() {
    for(int i = 2; i < MAXN; ++i) {
        if(!vis[i]) prime[tot++] = i;
        for(int j = 0; j < tot; ++j) {
            if(i*prime[j] >= MAXN) break;
            vis[i*prime[j]] = true;
            if(i%prime[j] == 0) break;
        }
    }
}

int main() {
    init();
    int n;
    while(~scanf("%d", &n)) {
        printf("%d\n", upper_bound(prime, prime+tot, n) - prime);
    }
    return 0;
}

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

class CheckList{
public: 
    int candidateNumber;
    bool isPrime;
public:
    CheckList();
    CheckList(int number);
};

CheckList::CheckList(int number){
    candidateNumber = number;
    isPrime = true;
}

CheckList::CheckList(){
    candidateNumber = 0;
    isPrime = true;
}

int main(){
    int n;
    while(cin >> n){
        vector<CheckList> list(n-1);
        for(int i=2;i<=n;++i){
            CheckList number(i);
            list[i-2] = number;
        }
        for(int i=2;i<=sqrt(n);++i){
            if(!list[i-2].isPrime){
                continue;
            }
            for(int j=i;j<=n;++j){
                if(j%i == 0 && i != j){
                    list[j-2].isPrime = false;
                    continue;
                }
            }
        }
        for(vector<CheckList>::iterator it = list.begin();it!=list.end();){
            if(!(*it).isPrime){
                it = list.erase(it);
                continue;
            }
            it++;
        }
        cout << list.size() << endl;
    }
}

C++: #include<iostream>
#include<cmath>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;

int prime(int x) {
    int ret = 0;
	for(int i = x; i > 1; i--) {
		int n = (int)sqrt(i);
		int yakusu = 0;
		for(int j = 1; j<=n; j++) {
			if(i%j==0) yakusu++;
		}
		if (yakusu==1) {
			ret++;
		}
	}
	return ret;
}

int main(){
    int x;
    while(cin>>x){
        cout << prime(x) << endl;
    }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;
	while(cin >> n){
		count = 0;
		for(int i = 1; i <= n; i++){
			if(i < 2);
			else if(i == 2){
				count++;
			}
			else if(i % 2 != 0){
				for(int j = 3; j * j <= i; j += 2){
					if(i % j == 0){
						flag = true;
					}
				}
				if(flag != true){
					count++;
				}
			}
			flag = false;
		}

		cout << count << endl;
		

	}

	return 0;
}

C++: #include<stdio.h>
#include<iostream>

int main(){
	int n=0,i,g,count=0;
	bool p=false;
	while(scanf("%d",&n)==1){
	for(g=2;g<=n;g++){
		for(i=2;i<g;i++){
			if(g%i==0) p=true;
		}
		if(p) p=false;
		else{
			count++;
			p=false;
			}
		}
	printf("%d\n",count);
	count=0;
	}
	return 0;
}

C++: #include <cstdio>
int d[1000000],c[1000000];
int main() {
	int i,j,r=0,n;
	for(i=2;i<=999999;i++) {
		if(d[i]){c[i]=r;continue;}
		c[i]=++r;
		for(j=i*2;j<=999999;j+=i)d[j]=1;
	}
	while(scanf("%d",&n)!=EOF) {
		printf("%d\n",c[n]);
	}
}

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

const int MAX_N = 1000000;

vector<int> init(void){
    vector<int> prime;
    bool is_prime[MAX_N];
    memset(is_prime, true, MAX_N);
    
    is_prime[0] = is_prime[1] = false;
    for(int i=2; i<MAX_N; i++){
        if(is_prime[i]){
            prime.push_back(i);
            for(int j=2*i; j<MAX_N; j+=i) is_prime[j] = false;
        }
    }
    return prime;
}

int main(int argc, const char * argv[])
{
    int n;
    vector<int> prime = init();
    while(cin>>n){
        cout << upper_bound(prime.begin(), prime.end(), n)-prime.begin() << endl;
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n,i,j;
    int ans;
    cin >> n;
    //while(cin >> n){ 
        ans=0;
        for(i=2;i<=n;i++){
            for(j=2;j<=i;j++)
                    if(i%j==0){
                        
                        //nの因数iが素数かどうかを判定する
                        //割り切れたら素数じゃないのでループ抜ける
                        
                        break;

            }
                    //jが最終まで行けばiが素数なのでans++
                    if(j==i)ans++;
        }
        cout << ans << endl;
    //}
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#define maxn 1000000
using namespace std;
int prime[maxn],number[maxn];
void getprime()
{
    int m=sqrt(maxn+0.5);
    for(int i=2;i<=m;i++)
    {
        if(!prime[i])
        {
            for(int j=i+i;j<maxn;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    int sum = 0;
    for(int i=2;i<maxn;i++)
    {
        if(!prime[i])
        {
            sum++;
        }
        number[i]=sum;
    }
}
int main ()
{
    int n;
    getprime();
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",number[n]);
    }
}
/**
--------------------- 
???zhaiqiming2010 
???CSDN 
???https://blog.csdn.net/zhaiqiming2010/article/details/62281598 
?????????????????????????
**/