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 <iostream>
using namespace std;
int main(){
	int n,k,kk;
	while(cin>>n){
		kk=0;
		for(int j=3;j<=n;j+=2){
			k=0;
			for(int i=3;i<=sqrt(j);i+=2){
				if(j%i==0)k++;
		        }
		     if(k==1)kk++;
		   }
		if(n==1)cout<<"0"<<endl;
		else if(n==2)cout<<"1"<<endl;
		else cout<<kk+1<<endl;
	   }
	return 0;
	}

C++: #include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];void k();using namespace std;main(){int n;p[0]=2;m[1]=0;m[2]=1;k();while(cin>>n){cout<<m[n]<<endl;}}void k(){int i,j,e=1;for(i=3;i<N+1;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}

C++: #include<bits/stdc++.h>
#include<cstdio>

using namespace std;

int pri[1000000];

int main()
{

    pri[0]=1;
    pri[1]=1;

    for(int i=4;i<1000000;i+=2)
    {
        pri[i]=1;
    }

    for(int i=2;i*i<1000000;i++)
    {
        for(int j=2;j*i<1000000;j++)
        {
            pri[i*j]=1;
        }
    }
    int n,c;
    while(scanf("%d",&n))
    {
        c=0;
        for(int i=2;i<=n;i++)
        {
            if(pri[i]==0)
            {
                c++;
            }
        }
       printf("%d\n",c);

    }

    return 0;
}

C++: //--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

bool is_prime(int a) {
	int now = 2;
	while (now*now <= a) {
		if (a%now == 0)return 0;
		else now++;
	}
	return 1;
}


int main() {
	while (cin >> n) {
		ll ans = 0;
		for (int i = 2; i <= n; i++) {
			if (is_prime(i))ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

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

int primes[78498], num_primes = 1;
int calculated = 2;
int count_pos(int n) {
	for (int i = 0; i < num_primes; i++) {
		if (primes[i] == n) {
			return i + 1;
		}
		else if (primes[i] > n) {
			return i;
		}
	}
	return num_primes;
}
int main() {
	primes[0] = 2;
	while (true) {
		int n;
		if (!scanf_s("%d", &n)) break;
		if (calculated+1 < n) {
			for (int i = calculated + 1; i < n + 1; i += 2) {
				bool is_prime = true;
				for (int w = 3; w < (int)(sqrt(i)) + 1; w += 2) {
					if (i%w == 0) {
						is_prime = false;
						break;
					}
				}
				if (is_prime) {
					primes[num_primes++] = i;
				}
			}
			calculated = n - (n % 2);
		}
		printf("%d\n", count_pos(n));
	}
}

C++: #include<iostream>

using namespace std;

int n;
int prime[1000000];
int checked[1000000];
int primesum[1000000];
int result[30];
int datasets;

int main()
{
	prime[0] = 0;
	prime[1] = 0;
	prime[2] = 1;
	primesum[0] = 0;
	primesum[1] = 0;
	primesum[2] = 1;

	for(int a = 3;a<1000000;a++)
	{
		prime[a] = 1;
	}
	
	for(int a = 3;a<1000;a++)
	{
		if(checked[a] == 0)
		{
			checked[a] = 1;
			for(int b = 2;b<a;b++)
			{
				if(a%b==0)
				{
					prime[a] = 0;
					break;
				}
			}
			if(prime[a] == 1)
			{
				for(int c = 2*a ;c<1000000;c+=a)
				{
					checked[c] = 1;
					prime[c] = 0;
				}
			}
		}
	}

	for(int a = 3;a<100;a++)
	{
		primesum[a] = primesum[a-1]+prime[a];
	}
	
	while(cin >> n)
	{
		cout << primesum[n] << endl;
	}

	return 0;
}

C++: #include <iostream>

int main() {
	int input;
	std::cin >> input;

	int count = 0; // input??\???????????¶??°????????¨???????´???°???????¨?
	for (; input > 1; input--) {// input???1???????????????????????????????????¨???????????????
		/*
		 * 5
		 * 4
		 * 3
		 * 2
		 */
		bool fl = true;
		for (int i = 2; i < input; i++) // 1 < i < input ????????¶??????????????°????????§?????????
			/*
			 * 5 -> 2, 3, 4
			 * 4 -> 2, 3
			 * 3 -> 2
			 * 2 ->
			 */
			 // ?????????????????°????????¨??????????????????????????????
			if (!(input % i))
				fl = false;

		if (fl)
			count++;
	}

			std::cout << count << std::endl;
}

C++: #include <bits/stdc++.h>
//#include "bits/stdc++.h"

#define rep(i,n) for(ll (i)=0;(i)<(ll)(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007LL
#define INF (1LL<<60LL)
#define int long long
typedef long long ll;

using namespace std;

#define MAX_N 1000000

signed main() {
	vector<bool> is_prime(MAX_N,true);
	is_prime[1] = false;
	for (ll i = 2; i <= sqrt(MAX_N); i++) {
		if (is_prime[i]) {
			ll k =2*i;
			while (k < MAX_N) {
				is_prime[k] = false;
				k += i;
			}
		}
	}
	vector<ll> ans(MAX_N, 0);
	for (ll i = 1; i < MAX_N; i++) {
		ans[i] = ans[i - 1];
		if (is_prime[i]) ans[i]++;
	}
	ll n;
	while (cin >> n) {
		cout << ans[n] << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,n[150000],j,o=0;
	for(int i=2;i<=99999;i++){
		n[i]=1;
		
	}
	n[0]=n[1]=0;
		for( j=2;j<=99999;j++){
			if(n[j]){
				for(int k=j*2;k<=9999;k+=j){
				n[k]=0;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
		}
}

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

int main()
{
	int counter=1,n,flag;
	
	while(cin>>n)
	{
		if(n<=1) 
		{
			cout<<'0'<<endl;
			break;
		}

		for(int i=3;i<=n;i+=2)
		{
			flag=1;
			for(int j=3;j<=sqrt(i);j+=2)
				if(i%j==0)
				{
					flag=0;
					break;
				}
			if(flag==1)
				counter++;
		}
		cout<<counter<<endl;
		counter=1;
	}
}