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<cmath>
using namespace std;
int main(){
    int n;
    while(cin >> n){
        bool prime[1000000] = {false};
        prime[1] = true;
        prime[2] = false;
        int count = 0;
      
        for(int j = 2; j * j <= n ; j++){
            if(!prime[j]){
                for (int k = 2; k*j <= n;k++){
                   prime[j*k] = true;
                }
            }
        }
        for(int i = 1;i<=n;i++){
            if(!prime[i]) count = count +1;
        }
        cout << count << endl;
    }
    return 0;
}

C++: #include <iostream>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define MAX_N 100000

void q9() {
	bool IsPrime[MAX_N];
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for (int i = 0; i < sqrt(MAX_N); i++) {
		if (!IsPrime[i]) continue;
		for (int j = i * 2; j < MAX_N; j += i) {
			IsPrime[j] = false;
		}
	}

	int NofP[MAX_N];
	NofP[0] = 0;
	for (int i = 1; i < MAX_N; i++) {
		NofP[i] = NofP[i - 1] + IsPrime[i];
	}

	int n;
	for (; cin >> n;) {
		cout << NofP[n] << endl;
	}
}

int main() {
	q9();
	return 0;
}

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

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(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;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}

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

int main(){
int n;
vector<int> a;
  while(cin < n){
  a.push_back(n);
  }
for(int i=0;i<a.size();i++){
  int k = 0;
  for(int j=2;j<a[i];j++){
    if(a[i]%j == 0 ) k++;
	}
  cout << k ;
 }
}

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

const int N = 1000000;
int data[1000000];
int n;

void Eratosthenes(){
  for(int i=0; i<N; i++){
    data[i] = 1;
  }
  for(int i=2; i<sqrt(N); i++){
    if(data[i]){
      for(int j=0; i*(j+2)<N; j++){
	data[i *(j + 2)] = 0;
      }
    }
  }
}

int main()
{
  int cnt = 0;
  Eratosthenes();
  while( cin >> n ) {
    cnt = 0;
    for(int i=2; i<=n; i++) {
      if( data[i] ) cnt++;
    }

    cout << cnt << endl;
  }
}

C++: #include<iostream>

int n;
int p;
int prime[1000000];
bool isprime[1000000];

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

 	return;
}

int main()
{
	while( std::cin >> n ){	
		sieve();
		std::cout << p << std::endl;
	}

 	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define pb(a) push_back(a) 
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
 
int main() {
    int n = 1000000;
    vector<int> v;
    v.pb(2);
    for(int i=3;i<=n;i+=2) {
        bool add = true;
        rep(j,0,v.size()) {
            if(v[j] * v[j] > i) break;
            if(i % v[j] == 0) {
                add = false; 
                break;
            }
        }
        if(add) v.pb(i);
    }

    int m;
    while(cin >> m) {
        cout << upper_bound(v.begin(), v.end(), m) - v.begin() << endl;
    }
    return 0;
}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin>>n){
        int count=0;

        if(1<n){
            count++;
        }
        if(n%2==0){
            n--;
        }
        while (1 < n){
            int prime_flag=1;
            for (int j = 2; prime_flag && j < n; j++) {
                if(n % j == 0){
                    prime_flag=0;
                }
                if(2 < j){
                    j++;
                }
            }
            count+=prime_flag;
            n-=2;
        }
        cout<<count<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int count=0;
		for(int i=5;i<=n;i+=6){
			int j=5;
			while(true){
				if(i%j==0)
					break;
				if(j>(int)sqrt((double)i)){
					count++;
					break;
				}
				j+=2;
			}
		}
		for(int i=7;i<=n;i+=6){
			int j=5;
			while(true){
				if(i%j==0)
					break;
				if(j>(int)sqrt((double)i)){
					count++;
					break;
				}
				j+=2;
			}
		}
		cout<<count+1<<endl;
	}
	return 0;
}

C++: import java.util.Scanner;
import java.io.*;
class Main{
    public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int ans,n;
    while(sc.hasNext()){
    	n=sc.nextInt();
    	ans=0;
    	if(n==1)ans=-1;
    	for(int i=1;i<=n;i+=2){
    		int flag=0;
    		for(int j=3;j<=Math.sqrt(i);j+=2){
    			if(i%j==0){
    				flag=1;break;
    			}
    		}
    		if(flag==0)ans++;
    	}
    	System.out.println(ans);
    }
    }
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int max[30], sol[30], listID=0;
	
    while (scanf("%d", &n) && n!=EOF){
        cnt=0;
        min = 1;
        minID = 0;
		printf("check %d ->", n);
        for (int i=0; i<listID; i++){
            if (max[i] < n && min <max[i]){
                min = max[i];
				cnt = sol[i];
            }
        }
		printf("check  %d - %d (cur sols = %d)\n", min+1, n, cnt);
        for (int i=min+1; i<=n; i++){
            if (IsPrime(i)) cnt++;
        }
        max[listID] = n;
        sol[listID] = cnt;
        listID++;
        printf("%d\n", cnt);
    }
    return 0;
}

int IsPrime(int n){
    int i;
    for (i=2; i*i<=n; i++){
        if (n%i==0) return 0;
    }
    return 1;
}

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i=3;
	while( i <= sqrt(x) ){
		if(x%i==0)return 0;
		i = i + 2;
	}
	return 1;
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			if(isprime(i))c++;

		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){

	const int N_MAX=100;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		count[i]=so[i]=0;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	int sq_max = (int)sqrt(max);
	so[0]=so[1]=1;
	for(soi=0,i=2;i<=sq_max;i++){
		if(so[i]>0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=1;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+1-so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}