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>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAXN = 1000000+1000;
const int maxn=100000+5;
int prime[maxn+1];
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;
       	cnt++;
       	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 <cstdio>
using namespace std;

int main(){

int i,j,n,count;

while(scanf("%d",&n) != EOF){

count=2;

if(n<4){
	count=n-1;
}else{
	for(i=4;i<n+1;i++){
		for(j=2;j<i/2+1;j++)

			if(i%j==0){
				break;
			}else if(j==i/2)
				count+=1;
	}
}

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

}
return 0;		
}

C++: #include<iostream>
using namespace std;
int main(){
  bool num[1000001] = {false};
  for(int i=2; i<1000; i++){
    if(!num[i]){
      for(int j=i*i; j<1000001; j+=i){
	num[j] = true;
      }
    }
  }
  int n;
  while(cin >>n){
    int sum = 0;
    for(int i=2; i<=n; i++){
      if(!num[i]){sum++;}
    }
    cout <<sum<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <list>
#include <algorithm>

using namespace std;

int main() {
  int n;
  
  while(!cin.eof()) {
    cin >> n;
    list<int> search_list(n-1);
    list<int> prime_number;
    while(n!=1) {
      search_list.push_front(n);
      n--;
    }
    while(!search_list.empty()) {
      int m = search_list.front();
      prime_number.push_back(m);
      search_list.pop_front();
      list<int>::iterator it = search_list.begin();
      while(it!=search_list.end()) {
	if((*it % m) == 0){
	  it = search_list.erase(it);
	  continue;
	}
	it++;
      }				   
    }
    cout << prime_number.size() << endl;
    prime_number.clear();
    search_list.clear();
  }
}

C++: #include<iostream>
using namespace std;
int main(){
	bool num[1000000] = {0};
	for(int i=2; i<1000000; i++){
		if(!num[i]){
			for(int j=i*2; j<500000; j+=i){num[j] = true;}
		}
	}
	int n;
	while(cin >>n){
		int f = 0;
		for(int i=2; i<=n; i++){
			if(!num[i]){f++;}
		}
		cout <<f<<endl;
	}
}

C++: #include <iostream>

using namespace std;
int main(){
	bool n[1000000];
	for(int i=0; i<1000000; i++){ n[i]=1; }
	n[0]=0;
	n[1]=0;

	for(int i=2; i<1000000; i++){
		if(n[i]==0){ break; }
		if(n[i]==1){
			for(int j=i*2; j<1000000; j++){ n[j]=0;	}
		}
	}

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

	return 0;
}

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

bool Prime(int n);

int main(){

  int n;
  int sum;

  while(cin >> n){
    sum = 0;
    for(int i=3; i<=n; i+=2){
      sum += Prime(i);
    } 
    cout << sum+1 << endl;
  }

  return 0;
}


bool Prime(int n){

  if(n%2==0)
    return false;

  else{
    for(int i=3; i<=sqrt(n); i+=2){
      if(n%i == 0)
	return false;
    }
  }

  return true;
}

C++: #include <bits/stdc++.h>
using namespace std;

long long i,j,sum[1000005],total,n;
bool a[1000005];


int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	
	for(i=2; i<1000000; i++){
//		cout<<i<<'\n';
		if(a[i]==false){
			j=i*i;
			while(j<1000000){
				a[j]=true;
				j+=i;
			}
		}
	}
	
	a[1]=true;
	total=0;
	for(i=1; i<1000000; i++){
		if(a[i]==false){
			total++;
		}
		sum[i]=total;
	}
	while(cin>>n){
		cout<<sum[n]<<'\n';
	}
	
return 0;
}

C++: 
 int main()
 {
     int num, i, j;
     cout<<"Enter an Integer:"<<endl;
                  cin>>num;
                  
                  for(i=0; i<=num; i++)
                  {
                           for(j=2; j<=i; j++)
                           {
                                    if(i%j == 0)
                                    {
                                    break;
                                    }
                                    else if (i == j+1)
                                    {
                                     cout<<i<<endl;    
                                         }
                                    }
                           }
    
}

C++: #include <iostream>
using namespace std;
int main()
{
	int A[30] = {};
	int P[1000000] = {};
	int c = 0, j;
	for (int k = 2; k < 1000000; ++k){
		if (P[k] == 0){
			P[k] = ++c;
			for (j = 2; j * k < 1000000; ++j)
				P[j * k] = -1;
		}
		else if (P[k] == -1)
			P[k] = c;		
	}
	int k;
	while (cin >> k)
		cout << P[k] << "\n";
	return 0;
}

C++: #include <iostream>
using namespace std;
#define tablesize 1000010
#include <math.h>

int main(void){
    int table[tablesize];
    for(int i=0;i<tablesize;i++){
        table[i]=1;
    }
    int k;
    table[0]=0;
    table[1]=0;
    for(int i=2;i<(int)sqrt(tablesize)+10;i++){
        if(table[i]==1){
            k=2;
            while(k*i<=tablesize){
                table[k*i]=0;
                k++;
            }
        }
    }

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

C++: #include <stdio.h>
 
int prime[999999];
int sum[999999]={0};

void isprime(int n) {
    int i, k;
    for(i = 2; i <= n; i++) {
        prime[i] = 1;
    }
    for(i = 2; i*i <= n; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= n; k += i) {
                prime[k] = 0;
            }
        }
    }
    for(i = 0; i <= n; i++){
        sum[i+1]= sum[i] + prime[i];
    }
}
 
int main() {
    int n, i, count;
    isprime(999999);
    while(scanf("%d", &n) != EOF) {
        count = sum[n+1];
        printf("%d\n", count);
    }
    return 0;
}

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

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num, true);
  array[0] = array[1] = false;
  for (int i = 2; i < num; i++) {
    if (!array[i]) continue;
    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }
  }

}

int main() {
  bool prime_number[999999];
  int num;
  int nump=0;
  int j=0;
  int cnt=0;

	while(scanf("%d",&num)!=EOF){
	  set_prime_number(prime_number, num);
	 for (int i = 0; i < num; i++) {
	 if (prime_number[i])cnt++;
	 }
	 printf("%d ",cnt);
	 cnt=0;
	}


  while(1){printf("aaaa");}
  return 0;
}

C++: #include<stdio.h>
int main(void){
	int i,j,n;
	bool judge[1000000]={0};
	
	for(i=3; i<1000000; i++)if(i % 2 == 0)judge[i] = 1;
	
	for(i=3; i<500000; i+=2){
		if(judge[i]==0){
			for(j=i*2;j<1000000;j+=i){
				if(j % i == 0){
					judge[j]=1;
				}
			}
		}
	}
	for(;;){
		int count=0;
		scanf("%d",&n);
		if(n==0)break;
		for(i=2;i<=n;i++){
			if(judge[i]==0)count++;
		}
		printf("%d\n",count);
	}
	return 0;
}