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 <bitset>
using namespace std;
bitset<1000000> p;
int main(){
  p.flip();
  p[0] = 0;
  p[1] = 0;
  for(int i = 2; i < 1000; ++i){
    if(p[i]){
      for(int j = 2*i; j < 1000000; j += i) p[j] = 0;
    }
  }
  int n;
  while(cin >> n){
    int ret = 0;
    for(int i = 2; i <= n; ++i) ret += p[i];
    cout << ret << '\n';
  }
  return 0;
}

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

void solve(int x){
	bool C[x];
	
	C[0]=false; C[1]=false;
	for(int i=2; i<=x; i++){
		C[i]=true;
	}
	
	for(int i=2;i<(int)sqrt(x)+1; i++){
		if(C[i]){
			for(int y=i*2; y<=x; y+=i) C[y]=false;
		}
	}
	
	int count=0;
	for(int i=0; i<=x; i++){
		if(C[i]){
			count++;
		}
	}
	
	cout << count << endl;  
}

int main(){
	int n;
	
	while(cin >> n){
		solve(n);
	}
	
	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int prime(int n);

int main()
{
	int k,j,n;
	int store,sum=0;

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

			for(j=1;j<=n;j++)
			{
				store=prime(j);
				if(store==1)
					{
						sum++;
					}

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



}


return 0;

}
int prime(int n)
{


	int i;
	float x,k;
	int l;


	x=float(n);
	k=sqrt(x);

	l=int(k);

		if(n==1 || n==0)
			{
				return 0;
			}


		if(n==2)
			{
				return 1;
			}

	for(i=2;i<=l;i++)
		{
			if(n%i==0)
			{
				return 0;
			}

		}

	return 1;


}

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

int n,mem[1000000];
int count;
int now=2;

//?´???°??????0
int main(){
	mem[1]=1;
	for(int i=2;i<=(int)sqrt(1000000.0)+1;i++){
		if(mem[i]==0){
			for(int j=2*i;j<=1000000;j+=i){
				mem[j]=1;
			}
		}
	}
	while(cin>>n){
		count=0;
		for(int i=1;i<n+1;i++){
			if(mem[i]==0) count++;	
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
#define MAX 999999

int main(void) {

  int flag[MAX+1];
  int n,count;

  int i,j;

  for(i=0;i<=MAX;i++) {
    flag[i]= (i<=1)? 0: 1;
  }

  for(i=2;i<=(int)sqrt(MAX)+1;i++) {
    if(flag[i]==1) {
      for(j=i*2;j<=MAX;j+=i) flag[j]=0;
    }
  }
  //for(i=0;i<=MAX;i++) printf("%d\n",flag[i]);
  while(scanf("%d",&n)!=EOF) {

    count=0;

    for(i=2;i<=n;i++) {

      if(flag[i]==1) count++;
    }

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

  }

  return 0;

}

C++: #include<iostream>
int main(){int m=1,n=999999,o,c=n/2+1,d;bool*v=new bool[c],*p=v+c;for(;*--p=1,p!=v;);for(;m<499;m++)for(o=m*2+1,d=o*3;v[m]&&d<n+1;d+=o*2)v[d/2]=0;for(;!(std::cin>>n).eof();printf("%d\n",c))for(c=n-->1,m=1;m<n/2+1;)c+=v[m++];delete[]v;}

C++: #include <stdio.h>
#include <iostream>
#include <cmath>

int prime(int n);
int main (void){
	int n;
	while(~scanf("%d",&n)){
		std::cout << prime(n) << std::endl;
	}

	return 0;
}

int prime(int n){
	bool *flag = new bool[n];
	int res=0,i=0;
	for(i=0;i<=n;flag[i++]=0);
	for(i=2;i<=n;){
		for(int j=2;i*j<=n;j++)
			flag[i*j]=1;
		for(i++;flag[i]==1 ;i++);

	}
	for(i=0;i<=n;i++)
		res += flag[i]?0:1;
	delete [] flag;
	return res-2;
}

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

int prime[1000000];


bool isPrime(int n) {
  int x = n;
  for (int i = 3; i <= x; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  for (int j = 0; j < i; j ++) {
    std::cout << prime[ns[j]] << std::endl;
  }
  return 0;
}

C++: #include<iostream>

#define LIM 1000000
using namespace std;

int main(){
  bool num_map[LIM];
  int in_num,prime_count;
  for(int i=0;i<LIM;i++){
    num_map[i]=1;
  }
  
  for(int i=2;i<LIM;i++){
    if(num_map[i]==1)
      for(int j=i*2;j<LIM;j+=i){
	num_map[j]=cout<<in_num<<endl<<endl;
	for(int i=2;i<=in_num;i++){
	  if(num_map[i]==1)
	    prime_count++;
	}
	cout<<prime_count<<endl;  
      }
    
  }
}

C++: #include<iostream>
#include<conio.h>
#include<cmath>    

using namespace std;

int main()
{
     int n;
     
     cin>>n;

     for (int i=2; i<n; i++)
        for (int j=2; j*j<=i; j++)
        {
            if (i % j == 0)
                break;
            else if (j+1 > sqrt(i)) {
                cout << i << endl;
            }
        }

     return 0;
 }

C++: #include <iostream>
#include <vector>
 
using namespace std;
 
const int N = 1000000;
bool flag[N];
int num[N];
 
int main(){
	for(int i=2;i<N;i++) flag[i] = true;
	for(int i=2;i*i<N;i++){
		if(not flag[i]) continue;
		for(int j=i*i;j<N;j+=i){
			flag[j] = false;
		}
    }
    num[0] = 0;
    for(int i=1;i<N;i++){
        if(flag[i]){
            num[i] = num[i-1] + 1;
        }else{
            num[i] = num[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << num[n] << endl;
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    
	while(scanf("%d",&n)!=EOF){
		for(i=2;i<=n;i++){
			z=0;
			for(j=2;j*j<=i;j++){
				if(i%j==0){
					z++;
					break;
				}
			}
			if(z==0){
				x++;
			}
		}
		printf("%d\n",x);
		x=0;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
bool prime(int n){
	for(int i=2;i<n;i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	int a,sum=0;
	while(cin>>a){
	for(int j=2;j<a;j++){
		if(prime(j))sum++;
	}
	cout<<sum<<endl;
	sum=0;
	}
}

C++: #include<iostream>
#include<math.h>
using namespace std;
int tim1(int n)
{
	if(n<2)
	return 0;
	if(n==2||n==3)
	return 1;
	if(n%2==0||n%3==0)
	return 0;
	for(int i=5;i<=sqrt(n);i=i+6)
	if(n%i==0||(n+2)%i==0)
	return 0;
	return 1;
	
}
int tim(int n)
{
	int d=0,i;
	for(i=2;i<=n;i++)
	{
		if(tim1(i)==1)
		d=d+1;
}
	return d;
}
int main()
{
	int a[100000],i,n;
	cin>>n;
	for(i=1;i<=n;i++)
	cin>>a[i];
	for(i=1;i<=n;i++)
	{
	tim(a[i]);
	cout<<tim(a[i])<<endl;
     }
}

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



int main(){
	int i , j , n , pn , cn=0;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
		cn++;
		if(cn>=30) break;
	}
	return 0;
}