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 GCC optimize(2)
#define LOCAL0
#include<iostream>
#include<stdio.h>
#include<cstring>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<map>
using namespace std;
typedef long long ll;
#define xx first 
#define yy second
#define INF 0x3f3f3f3f
void read(int &p)
{
    p=0;int flag=1;char c=getchar();
    while(!isdigit(c)) {if(c=='-') flag=-1;c=getchar();}
    while(isdigit(c)) {p=p*10+c-'0';c=getchar();}p*=flag;
}
//n以内素数个数
const int maxn=1000000;
int prime[maxn];
bool is_prime[maxn+1];
int sieve(int n){
    int p=0;
    for(int i=0;i<=n;i++) is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=n;i++){
        if(is_prime[i]){
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
        }
    }
    return p;
}
int cnt,a[35],m;
int main()
{
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    freopen("out.txt","w",stdout);
    #endif
    while(cin>>a[++cnt]){
        cout<<sieve(a[cnt])<<endl;
    }
    return 0;
}

C++: #include <stdio.h>

int main(void){

	int num;
	int cnt1 = 0, cnt2 = 0;
	int i, j;

	while(scanf("%d", &num) != EOF){
		for(i = 2; i <= num; i++){
			for(j = 2; j <= num; j++){
				if(i % j == 0){
					cnt1++;
				}
			}
			if(cnt1 == 1) cnt2++;
			cnt1 = 0;
		}
		printf("%d\n", cnt2);
		cnt2 = 0;
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <algorithm>
#include <cassert>
#include <vector>
#include <string>
#include <cmath>
#include <map> 
#include <cstring>
#include <sstream>
using namespace std;
 
const int MAX= 10000100;

#define loop(i,a,b) for(int i = a ; i < b ; i ++)
#define rep(i,a) loop(i,0,a)
#define all(a) (a).begin(),(a).end()
#define ll long long int
#define gcd(a,b) __gcd(a,b)
#define pb(a) push_back(a)
int GCD(int a, int b) {if(!b) return a; return gcd(b, a%b);}
int lcm(int a, int b) {return a*b / gcd(a, b);}

int res[1000010];
int N = 1000010;
void isPrime(){
  for (int i=2; i<N; ++i)res[i] = 1;
  res[0] = res[1] = 0;
  for (int i=2; i<1000; ++i) {
    if (res[i * i]) {
      int j = i + i;
      for (;j < N; res[j] = 0, j += i); 
    }
  }
  for (int i=1; i<N; ++i) res[i] += res[i-1];
}
int main(void){
  int n;
  isPrime();
  while(cin>>n,n){
    cout<<res[n]<<endl;
  } 
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	while (1)
	{
		int tmp;

		cin >> tmp;

		if (!tmp)
		{
			return 0;
		}

		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;
	}

	return 0;
}

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

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

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

using namespace std;
const int N=1000000;
vector<bool> pr(N,true);
vector<int> p;

void init()
{
	int i,j;
	p.reserve(80000);
	p.push_back(2);
	for(i=3;i*i<N;i+=2)
		if(pr[i]) {
			p.push_back(i);
			for(j=i;i*j<N;j+=2) pr[i*j]=false;
		}
	for(;i<N;i+=2) if(pr[i]) p.push_back(i);
}

int main()
{
	int n;
	init();
	while(cin>>n) {
		cout<<upper_bound(p.begin(),p.end(),n)-p.begin()<<endl;		
	}
	return 0;
}

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

struct theSieveOfEratosThenes {
	vector<bool> prm;

	theSieveOfEratosThenes(int n) {
		prm = vector<bool>(n + 1, true);
		prm[0] = prm[1] = false;
		for (int i = 2; i * i <= n; ++i) {
			if (prm[i]) {
				for (int j = 2 * i; j <= n; j += i) prm[j] = false;
			}
		}
	}

	bool isPrimeNumber(int a) {
		return prm[a];
	}
};

int main() {
	int n;
	theSieveOfEratosThenes tsoet(999999);
	while (cin >> n) {
		int ans = 0;
		for (int i = 2; i <= n; ++i) {
			if (tsoet.isPrimeNumber(i)) ++ans;
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	while (cin)
	{
		string tmpstr;
		int tmp;

		getline(cin, &tmpstr);

		tmp = atoi(tmpstr.c_str());

		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;

		//if (cin.eof()) { break; }
	}

	return 0;
}

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

#define out cout 
#define in cin
#define el endl

#define rep(i, N) for (int i = 0; i < N; i++)
#define mito(N) cout << N << endl

bool f[1000001] = {false};

int main()
{
	for (int i = 2; i * i < 1000001; i++){
		for (int j = i * i; j < 1000001; j += i){
			f[j] = true;
		}
	}

	int n;
	while (in >> n){
		int c = 0;
		for (int i = 2; i <= n; i++){
			if (!f[i])c++;
		}
		mito(c);
	}

	return (0);
}

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

using namespace std;

#define max 999999 + 1

int main(void){

	vector< bool > table( max, true );
	vector< int > p( max, 0 );
	table[0] = false;
	table[1] = false;

	for( int i = 2; i < max; i++ ) {
		if( table[i] == false ) continue;
		for( int j = 2 * i; j < max; j+=i ) {
			table[j] = false;
		}
	}

	for( int i = 1; i < max; i++ ) {
		p[i] = p[i - 1] + table[i];
	}

	int n;
	
	while( scanf("%d", &n ) != EOF ) {
		cout << p[n] << endl;
	}

    return 0;
}

C++: /*
Volume0-0009
*/
#include <iostream>
#include <stdlib.h>
#include <string.h>

#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE

using namespace std;

int main(int argc, char *argv[]){
  int f[N];

  //  memset(f, TRUE, N);
  f[0]=FALSE;
  f[1]=FALSE;
  for (int i=2; i<N; i++)
    f[i] = TRUE;

  for (int i=2; i<N; i++){
    if (f[i] == TRUE ) {
      for (int j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }
  int n;
  while (cin >> n) {
    int m = 0;
    for (int i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }
    cout << m << endl;
  }
 
  exit(0);
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	int a[1000000];
	a[0]=1;
	a[1]=1;
	for(int i=2;i<1000000;i++){
		if(a[i]==0){
			for(int j=i;j<1000000;j+=i){
				a[j]=1;
			}
		}
	}
	int b;
	while(cin>>b){
		int c=0;
		for(int i=0;i<b;i++){
			if(a[i]>b)break;
			else {
				if(a[i]==1) c++;
			}
		}
		cout<<c<<endl;
	}
}

C++: #include<stdio.h>
int count = 0;
int IsPrime(int n){//試し割り
	int i;
	if(n < 2)
		return 0;
		
	else if(n==2){
		count++;
	}
	
	if(n % 2==0)
		return 0;
		
	for(i = 3; i * i <= n; i+=2)
		if(n % i == 0)
			return 0;
			
	count++;
}
int main(){
	int i;
	scanf("%d",&i);
		while(1){
			IsPrime(i);
			i--;
			if(i == 0){
				printf("%d\n",count);
				break;
			}
		}
	return 0;
}