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++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	int n;
	cin >> n;
	for (int i = 2; i <= n; i++){
		if (!vis[i]){

			prime[i] = 1;
			for (int j = i + i; j <= n; j += i){
				vis[j] = 1;
				prime[j] = 0;

			}
		}
	}
	int sum = 0;
	for (int i = 2; i <= n; i++){
			if (prime[i]){
				sum++;
			}
		}
		cout << sum << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(int argv,char* argv[]){
unsigned x[30];
int count=0;
for(int i=0;i<argv;I++){
cin>>x[i];
}
for(int i=0;i<argv;i++){
for(int j=1;j<x[i];j++){
if(x[i]%j!=0)
count++;
}
cout<<count<<endl;
count=0;
}
return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ll long long

int n;
int main()
{
	bool prime[1000005];
	memset(prime, true, 1000005);
	prime[0] = false; prime[1] = false;
	for (int i = 2; i*i < 1000005; i++)
	{
		if (prime[i] == true)
		{
			for (int j = 2; i*j < 1000005; j++)
			{
				prime[i*j] = false;
			}
		}
	}
	while (cin >> n)
	{
		int cnt = 0;
		REP(i, n+1)
		{
			if (prime[i] == true)
			{
				cnt++;
				//cout << i << endl;
			}
		}
		cout << cnt << endl;
	}

	return 0;
}

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

int main()
{
    int n;
    
    while(cin>>n){
        bool p[n+1];
        int cnt = 0;
        for(int i=0; i<=n; i++){
            if(i==0){
                p[0] = false;
            }
            else if(i==1){
                p[i] = false;
            }
            else if(i==2){
                p[i] = 2;
            }
            else if(i==3){
                p[i] = 3;
            }
            else if(i==5){
                p[i] = 5;
            }
            else if(i==7){
                p[i] = 7;
            }
            else if((i%2!=0)&&(i%3!=0)&&(i%5!=0)&&(i%7!=0)){
                p[i] = true;
            }
            else{
                p[i] = false;
            }
        }
        
        for(int j=0; j<=n; j++){
            if(p[j]==true){
                cnt++;
            }
        }
        
        cout << cnt << endl;
            
    }
    
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int MAXN = 1000000+10;
const int maxn=100000+5;
int prime[maxn];
bool p[MAXN];
int cnt=0;
void getPrime()
{
    memset(p,true,sizeof(p));
    p[0]=p[1]=false;
    for(int i=2;i<=MAXN;i++)
       if(p[i]) {
       	prime[cnt++]=i;
       	for(int j=i*i;j<=MAXN;j+=i)
       	    p[j]=false;
	   }
}
int main()
{
	getPrime();
	/*int k=lower_bound(prime,prime+cnt,999999)-prime;
	for(int i=k;i>=0;i--)
	   if(prime[i]<999999) {
	   	printf("%d\n",i+1);
	   	break;
	   }*/
	for(int i=0;i<cnt;i++)
	   cout<<prime[i]<<" ";
	int n;
	while(scanf("%d",&n)==1){
		int k=lower_bound(prime,prime+cnt,n)-prime;
		if(prime[k]==n) k++;
		printf("%d\n",k);
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cstdio>
using namespace std;
#define MAX 1000000
bool prime[MAX];
int main(void){ 
  
  prime[0] = prime[1] = false;
  //memeset(prime,sizeof(prime),true);
  fill(prime,prime+MAX,true);
  long long int ans[MAX];
  
  ans[0] = ans[1] = 0;
  ans[2] = 1;
  int now=0;
  
  for(long long int i = 2 ; MAX >= i ; i ++){
    ans[i] = now ;
    //cout<<now<<" "<<ans[i]<<endl;
    if(prime[i]){
      //cout<<i<<endl;
      now ++;
      for(long long int j = i + i ; MAX > j ; j += i){
	prime[j] = false;
      }
    }
  }
  
  long long int n;
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
  
}

C++: #include<cstdio>
#define MAX 1000010

bool is_prime[MAX];

int sieve(int n) {
	for (int i = 0; i <= n; ++i) is_prime[i] = true;	
	is_prime[0] = is_prime[1] = false;
	int count = 0;
	for (int i = 2; i <= n; ++i) {
		if (is_prime[i]) {
			++count;
			for (int j = 2 * i; j <= n; j += i) {
				is_prime[j] = false;
			}
		}
	}
	return count;
}

int main()
{
	int n;
	while (scanf("%d", &n) == 1) {
		printf("%d\n", sieve(n));
	}
	return 0;
}

C++: #include <stdio.h>
int isprime(int n){
	int i,j;
	int isprime[10000];
	for(i=0;i<=10000;i++){
 		isprime[i]=1;
	}
	isprime[0]=isprime[1]=0;
	for(i=2;i<=10000;i++){
 		if(isprime[i]==1){
 			for(j=2*i;j<=1000;j+=i){
				isprime[j]=0;
			}
		}
	}
}

int main(){
	int a,b,i,n,p1,q1;
	scanf("%d", &n);
	while (n != 0){
		for(i=2;i<=n;i++){
			a = isprime(i-2);
			b = isprime(i);
			if(a==1 && b==1){
				p1 = i-2;
				q1 = i;
			}
		}
		printf("%d %d\n",p1,q1);
		scanf("%d", &n);
	}
	return 0;
 }

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

int sos(int);

int pri[10000000];

int main(){
  int x;
  while(scanf("%d",&x)!=EOF){
    printf("%d\n",sos(x));
  }  
  return 0;
}

int sos(int a){
  int i,j,c=0,b;
  for(j=2;j<=a;j++){
    b=0;
    if(pri[j]==3)continue;
    for(i=2;i<=sqrt(j);i++){
      if(j%i==0){pri[j]=3;b=1;break;}
      
    }
    if(b==0){pri[j]=1;c++;}
  }
  return c;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/


int prime[1000000];
bool is_prime[1000000];

void sieve(){
  int p=0;
  for(int i=0;i<1000000;i++)is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2;i<1000000;i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=1000000;j+=i)is_prime[j]=false;
    }
  }
}


int main(){
  int n,cnt;
  sieve();
  while(cin>>n){
    cnt=0;
    for(int i=0;;i++){
      if(prime[i]>n)break;
      cnt++;
    }
    cout<<cnt<<endl;
  }
  return 0;
}