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 <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
	int num, cnt;
	unsigned int i, j, k, data_num;
	int data[50];
	unsigned int sq_num;
	unsigned int *prime;

	for (data_num = 0; data_num < 50; data_num++) {
		data[data_num] = -1;
		scanf("%d", &data[data_num]);
		if (data[data_num] < 0) {
			break;
		}
	}

	for (k = 0; k < data_num; k++) {
		sq_num = (int)sqrt((double)data[k]);
		prime = (unsigned int*)malloc(sizeof(unsigned int) * data[k]);

		for (i = 0; i < data[k]; i++) {
			prime[i] = 1;
		}

		prime[0] = 0;
		for (i = 1; i < sq_num; i++) {
			if (prime[i] == 1) {
				for (j = (i + 1); (i + 1) * j <= data[k]; j++) {
					prime[(i + 1) * j - 1] = 0;
				}
			}
		}

		cnt = 0;
		for (i = 0; i < data[k]; i++) {
			if (prime[i] == 1) {
				cnt++;
				//printf("%d", i + 1);
			}
		}

		printf("%d\n", cnt);

		free(prime);
	}

	return 0;

}

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


int main(){
	bool work[MAX];
	int num, ans = 0;

	// 入力
	cin >> num;

	// 初期化
	for(int i = 0; i < MAX; i++){
		if(i < 2){
			work[i] = false;
		}else{
			work[i] = true;
		}
	}

	// エラトネスのふるい
	for(int i = 2; i < sqrt((double)MAX) + 1; i++){
		if(work[i] == true){
			for(int j = i * 2; j < MAX; j += i){
				work[j] = false;
			}
		}
	}

	// 計算
	for(int i = 0; i <= num; i++){
		if(work[i] == true){
			ans++;
		}
	}

	// 出力
	cout << ans << endl;

	return 0;
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int pt[1000000];

int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 2; i <= n; i++) if (pt[i] == 0) {
        ans++;
        for (int j = i+i; j <= n; j+=i) pt[j] = i;
    }
    printf("%d\n", ans);
    return 0;
}

C++: #include<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ cnt++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
printf("%d\n",cnt);
return 0;
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<sstream>
#include<iomanip>
#include<cstdlib>
#include<cmath>
#include<cstdio>
using namespace std;

int main()
{
	char prime[999999];
	for (int i = 0; i <= 999999; i++)prime[i] = '1';
	prime[0] = '0';
	prime[1] = '0';
	for (int i = 2; i*i <= 999999; i++)
	{
		if (prime[i] == '1')
		{
			int j = i * 2;
			while (j <= 999999)
			{
				prime[j] = '0';
				j += i;
			}
		}
	}
	int n;
	while (cin >> n)
	{
		int sum = 0;
		for (int i = 0; i <= n; i++)
		{
			if (prime[i] == '1')sum++;
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		count[i]=so[i]=0;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	int sq_max = (int)sqrt(max);
	so[0]=so[1]=1;
	for(soi=0,i=2;i<=sq_max;i++){
		if(so[i]>0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=1;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+1-so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	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 (!i)
            continue;
        for (int j = i + i; j <= n; j += i)
            v[j] = false;
    }

    for (int i = 2; i <= n; i++)
         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;
}

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

bool isPrime(int x) {
    if (x==2) {
        return true;
    }
    if (x<2 || x%2==0) {
        return false;
    }
    for (int i=3; i*i<=x; i+=2) {
        if (x%i==0) {
            return false;
        }
    }
    return true;
}
int main() {
    int n;
    int cnt;
    while (cin >> n) {
        cnt=0;
        for (int i=0; i<=n; i++) {
            if (isPrime(i)) {
                cnt++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

C++: #include<iostream>

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=n-1;++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	while(cin>>n)
	{
		int count = 0;
		for(int i=0;i<=n;++i)
		{
			if(Prime(i))
			{
				++count;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

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

#define priMAX 1000000

vector<int> sieve_of_eratosthenes(int n) {
	vector<int> primes(n);
	for (int i = 2; i < n; ++i)
		primes[i] = i;
	for (int i = 2; i*i < n; ++i)
	if (primes[i])
		for (int j = i*i; j < n; j+=i)
			primes[j] = 0;
	return primes;
}

int main(){
	vector<int> primes = sieve_of_eratosthenes(priMAX);
	vector<int> all(priMAX);
	int cc = 0;
	for(int i=0; i<priMAX; i++){
		if(primes[i]) cc++;
		all[i] = cc;
	}
	int n;
	while(cin>>n){
		cout<<all[n]<<endl;
	}
	return 0;
}

C++: /*#include <stdio.h>
  int main(){
    int a,b,c,d,n,sum=0;
      while(scanf("%d",&n) != EOF){
       for(a=0;a<10;a++){
          for(b=0;b<10;b++){
             for(c=0;c<10;c++){
                for(d=0;d<10;d++){
                    if(a+b+c+d==n)
                        sum++;
                          }
                            }
                             }
                               }
                                printf("%d\n",sum);
                                 sum=0;
                                   }
return 0;
}*/#include <stdio.h>
  int main(){
   int i,j,n,hantei=0;
   int sum=0;
    while(1){
scanf("%d",&n);
if(n != EOF){
break;
}
    for(i=2;i<=n;i++){
      for(j=2;j*j<=i;j++){
        if(i%j != 0 || i == j){
            hantei += 0;
               }else{
                  hantei += 1;
                    }
}
if(hantei == 0){
sum++;

}
hantei=0;
}
printf("%d\n",sum);
sum=0;
hantei = 0;
}
return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;
#define MAX_SIZE 1000100
#define N 999999
int preme[MAX_SIZE];

int main(int argc, char *argv[]) {
	int index = 0;
	for(int i = 0; i < MAX_SIZE; i++)
		if(i % 2)
			preme[i] = 1;
		else {
			preme[i] = 0;
		}
	preme[2] = 1;
	for(int i = 3; i <= 999999; i += 2) {
		if(preme[i]) {
			for(int j = i + i; j <= 999999; j += i)
				preme[j] = 0;
		}
			
	}
	//freopen("data.txt", "r", stdin);
	int n;
	while(~scanf("%d", &n)) {
		long count = 0;
		for(int i = 1; i <= n; i++)
			if(preme[i])
				count++;
		cout << count << endl;
	}
		
}