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 n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			int count = 0;
			for (int a = 2; a <= n; a++) {
				if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) 
					count++;
				if (a == 2 || a == 3 || a == 5 || a == 7)
					count++;
			}
			countdata[x] = count;
			x++;
		}
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
	return EXIT_SUCCESS;
}

C++: #include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>

using namespace std;


#define all(c) ((c).begin()), ((c).end())
#define debug(c) cerr << "> " << #c << " = " << (c) << endl;
#define iter(c) __typeof((c).begin())
#define tr(i, c) for (iter(c) i = (c).begin(); i != (c).end(); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, a, b) for (int i = (int)(a); i <= (int)(b); i++)

#define mp make_pair
#define fst first
#define snd second
#define pb push_back


const double EPS = 1e-10;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef complex<double> P;



int main(){
	for(int n; cin >> n; ) {
		vi p(n + 1, 1);
		p[0] = p[1] = 0;
		int ans = 0;
		rep(i, n + 1) if (p[i]) {
			ans++;
			for (int j = i + i; j <= n; j += i) p[j] = 0;
		}
		cout << ans<< endl;
	}
	return 0;
}

C++: /*
 0…未確定
 1…素数
 2…素数でない
*/
#include <iostream>

using namespace std;

int main(){
    int num[1000000]={0}, b, a, n, c;
    for(int i=2;i<=1000;i++){
        if(num[i]==0){
            num[i]=1;
            b=1;
            while((a=(++b*i))<1000000) num[a]=2;
        }
    }

    while(cin >> n){
        c=0;
        for(int i=2;i<=n;i++) {
            if(num[i]==1||num[i]==0) c++;
        }
        cout << c << endl;
    }
    return 0;
}

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

int main(){
	bool b[1000000] = {};
	for(int i = 2; i < 1000000; i++){
		b[i] = true;
	}
	for(int i = 2; i < 1000; i++){
		if(b[i]){
			for(int j = i * i; j < 1000000; j += i){
				b[j] = false;
			}
		}
	}

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

C++: #include <stdio.h>
#include <stdlib.h>
int main(void) {
    int i,j,n,ans=0,prime[1000000];
    prime[0]=0;prime[1]=0;
    for(i=2;i<1000000;i++){prime[i]=1;}
    for(i=2;i<1000000;i++){
        if(prime[i]==1){
            ans++;
            if(i<1000)for(j=i*i;j<1000000;j+=i)prime[j]=0;
        }
        prime[i]=ans;
    }
    while(scanf("%d",&n)!=EOF){printf("%d\n",prime[n]);}
    return 0;
}

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

int eratos(int n){
	bool isprime[n + 1];
	for(int i = 0; i <= n; i++)isprime[i] = true;
	isprime[0] = isprime[1] = false;
	for(int i = 2; i * i <= n; i++){
		if(isprime[i]){
			int j = i + i;
			while(j <= n){
				isprime[j] = false;
				j = j + i;
			}
		}
	}
	int counter = 0;
	for(int i = 0; i <= n; i++){
		if(isprime[i] == true)counter++;
	}
	return counter;
}

int main(){
	int n;
	while(cin >> n){
		cout << eratos(n) << endl;
	}
}

C++: #include "stdio.h"
#include "iostream"
using namespace std;

int main()
{
    int n,count=0,m=0,i,j;
    while(cin>>n)
    {
        for(i=2;i<=n;i++)
        {
            for(j=1;j<i;j++)
            {
                if(i%j==0)count++;
            }
            
            if(count==1)
            m++;

            count=0;
        }
        cout<<m<<endl;
        m=0;
    }
    return 0;
}

C++: #include<stdio.h>
int main ()
{
int n,m,cou;m=0;cou=0;
while(scanf("%d",&n)!=EOF)
{
for(int i=3;i<=n;i+=2){
for(int k=3;k<i;k+=2){
if(i%k==0){m++;break;}}
if(m==0)cou++;
m=0;
}
if(n==2)cou=1;
else if(n==1)cou=0;
else cou++;
printf("%d\n",cou);
cou=0;
}
return 0;
}

C++: #include <stdio.h>
const int MAX_V = 100000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  while(1){
    scanf("%d",&n);
    printf("%d\n",sum[n]);
  }
  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  long n;
  vector<long> primes;
  primes.push_back(2);
  while (cin >> n) {
    for (int i = 3; i <= n; i += 2) {
      bool prime = true;
      for (long j : primes)
        if (i % j == 0) {
          prime = false;
          break;
        }
      if (prime) primes.push_back(i);
    }
    int x = 0;
    for (long j : primes)
      if (j <= n) x++;
    cout << x << endl;
  }
}

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

int main() {
	int n,yakusuu,sosuu;
	while (cin >> n) {
		sosuu = 0;
		for (int i = 1; i <= n; i++) {
			yakusuu = 0;
			for (int j = 1; j <= i; j++){
				if (i%j == 0)yakusuu++;
			}
			if (yakusuu == 2)sosuu++;
		}
		cout << sosuu << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;
      
      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j*j)
        v[i]=false;
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				count++;
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
			}
		}

//		printf("%d",data[n]);
	}
	return 0;
}

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

int main() {

    vector<bool> primes (1000000);
    for (int n = 0; n < 1000000; n++) {
        primes[n] = true;
    }
    primes[0] = false;
    primes[1] = false;

    for (int n = 2; n < 1000000; n++) {
        if (primes[n]) {
            for (int k = 2*n; k < 1000000; k = k+n) {
                primes[k] = false;
            }
        }
    }

    int n;
    while (cin >> n) {
        int result = 0;
        for(int i = 0; i <= n; i++) {
            if ( primes[i] ) {
                result += 1;
            }
        }
        cout << result << endl;
    }
     
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
main(){int i,j,n,p[1000000];scanf("%d",&n);for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}