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>
using namespace std;
int main(){
    int a[1000000];
    int n;
    cin>>n;
    a[0]=2;
    int k=1;
    
    for(int i=3;i<=n;i++){
        for(int j=0;j<=k;j++){
            if(j==k){
                a[k]=i;
                k++;
                break;
             }
            if(i%a[j]==0)break;
        }
    }
    cout<<a[0]<<" "<<a[1]<<" "<<a[2]<<" "<<a[3]<<" "<<a[4]<<endl;
    cout<<k<<endl;
}

C++: #include <cstdio>
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;scanf("%d", &n);n++){
  	printf("%d\n", npr[n]);
  }
  return 0;
}

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

class prime{
	int cnt;
	vector<int> p;
public:
	prime();
	int num(int n);
};

prime::prime(){
	p.clear();
}

int prime::num(int n){
	if(n<2)return 0;
	if(n==2)return 1;
	p.push_back(2);
	int c;
	cnt=1;
	for(int i=3;i<=n;i+=2){
		c=0;
		for(int j=0;j<(int)p.size();j++){
			if(i%p[j]==0){
				c++;
				break;
			}
		}
		if(c==0){
			p.push_back(i);
			cnt++;
		}
	}
	return cnt;
}

int main()
{
	int n;
	while(cin >> n){
		prime pr;
		cout << pr.num(n) << endl;
	}
	return 0;
}

C++: #include <stdio.h>
bool used[1000005];int RideBack[79000],last=0;
int bin_search(int val) {int left=0,right=last-1,ans=0;while (left<=right) {int center=(left+right)>>1;if (RideBack[center]>val) right=center-1;else left=center+1,ans=left;} return ans;}
int main() {
    int i;for (i=2;i<=1000000;used[i++]=true);
    for (i=2;i<=1000;i++) if (used[i]) for (int j=i*i;j<=1000000;j+=i) used[j]=false;
    for (i=2;i<=1000000;i++) if (used[i]) RideBack[last++]=i;
    while (scanf("%d",&i)!=EOF) printf("%d\n",bin_search(i));return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
using namespace std;


// cin >>
// cin <<
bool isPrime(int x){
	if(x==2) return true;
	if(x<2||x%2==0) return false;
	int i=3;
	while(i<=sqrt(x)){
		 if (x%i==0)return false;
		i= i+2;
	}
	return true;
}
int main(){
	int in[30]={};
	int out=0;
	for(int i=0;i<30;i++) cin >>in[i];
	for(int i=0;i<30;i++){
		if(in[i]==0){
			break;
		}else{
			out=0;
			for(int j=0;j<in[i]+1;j++){
				if(isPrime(j)==true){
					out++;
				}
			}
			cout <<out<<endl;
		}
	}
	
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
#define INF 999999
using namespace std;

int main()
{
	int n;
	
	while (cin >> n)
	{
		int ans = 0,rootn;

		int a[INF] ;
		
		rootn = sqrt(n)+1;
	
		for (int i = 2; i <= rootn; i++)
		{
			if (a[i]==0)
			{
				for (int j = i+1; j <= INF; j++)
				{
					if (a[j] == 0 && j%i == 0)
					{
						a[j] = 1;
					}
				}
			}
		}
		cout << "a" << endl;
		for (int i = 2; i <= n; i++)
		{
			if (a[i]==0)
				++ans;
		}
		cout << ans << 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(int 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 <bits/stdc++.h>
using namespace std;
typedef long long LL;

int main(){
	int n;
	while(cin>>n){
		int ans=0;
		for(int m=2;m<=n;m++){
			for(int i=2;i<=sqrt(m);i++){
				if(m%i==0){
					ans++;
					break;
				}
			}
		}
		cout<<n-ans-1<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stack>
#include<math.h>
using namespace std;
int dp[100000000];
void shokika();
int main() {
	int n, ans = 0, i, count = 0, count2 = 0, insq;
	double sq;
	bool bo=false;
	shokika();
	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			if (dp[i] == 1) {
				ans++;
				bo = true;
			}
			else {
				bo = false;
			}
			//sq = sqrt(i);
			//insq = (int)sq;
			for (int j = 2; j <= i; j++) {
				if (bo == true) {
					break;
				}
				else if (bo == false && dp[i] != -1) {
					count = 0;
					break;
				}
				/*
				if ( (i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0)) {
					count = 0;
					break;

				}
				*/
				if (i%j == 0) {
					count++;
				}
				if (count >= 2) {
					break;
				}
				/*
				else {
					cout << i <<" "<<count<< endl;
				}
				*/

			}
			if (bo == true) {
				continue;
			}
			if (dp[i] == -1) {
				dp[i] = count;
			}
			if (dp[i] == 1) {
				//	cout << i << endl;
				ans++;
			}
			count = 0;
		}
		cout << ans << endl;
		ans = 0;
	}

	/*
	for (int i = 1; i < n; i++) {
		if (n%i == 0) {
			count++;
		}
		if (count >= 2) {
			count = 0;
			continue;
		}
		else  {
			ans++;
		}
	}
	cout << ans << endl;
	ans = 0;
}
*/
	return 0;
}
void shokika() {
	for (int i = 0; i < 100000000; i++) {
		dp[i] = -1;
	}
	return;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000000;
bool is_prime[SIZE];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin());

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>
#include <map>

int main() {
	int a;
	while (std::cin >> a) {
		int nSum = 0;
		for (int i = 2;i <= a;i++) {
			int flag = 0;
		for (int j = 2;j < i;j++) {
			if (i%j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			nSum += 1;
		}
	}
		std::cout << nSum << std::endl;
	}
	return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

int main() {
	int num;
	while (cin >> num) {
		cout << Era(num) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> prime;
prime.push_back(2);//ôðÈ­½ß2ÍÅÉüêÄ¨­
bool flag;
for(int x=3;x<=n;x+=2){
flag=true;
for(int y=0;prime[y]*prime[y]<=x;y++){
if(!(x%prime[y])){
flag=!flag;
break;
}
}
if(flag)prime.push_back(x);
}
cout << prime.size() << endl;
return 0;
}