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>
using namespace std;
int main(){
	int N,count=0,k;
	while(k<20){
		cin >> N;
		count = 0;
		if(N<0)	break;
	for(int x=2;x<=N;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count++;
	}
	cout << count << endl;
		k++;
	}
	return 0;
}

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

#define MAX 10000000
int a[MAX];

int main()
{
	int n;
	a[0] = a[1] = 0;
	a[2] = 1;
	a[3] = 2;
	for (int i = 4; i < MAX; i++)
	{
		bool ok = true;
		for (int j = 2; j < sqrt(i) + 0.1; j++)
		{
			if (i % j == 0)
			{
				a[i] = a[i - 1];
				ok = false;
				break;
			}
		}
		if (ok)
			a[i] = a[i - 1] + 1;
	}

	while (cin >> n)
		cout << a[n] << endl;
	
	return 0;
}

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<1000000; 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>
#include <cstdio>

using namespace std;

int pri(int n){
	int x = 0;
	int sum;
	
	for(int i = 1;i <= n;i++){
		sum = 0;
		for(int j = 1; j <= i; j++){
			if( i % j == 0) sum += j;
			if(sum == i + 1) x++;
		}
	}
	return x;
}

int main(){
	int n, x;
	while(scanf("%d", &n) != EOF)
	
	cout << pri(n) << endl;
	
	return 0;
}

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

const int MAX = 1000000;

int main() {
	bool prime[MAX + 1];
	int sum[MAX + 1];
	fill(prime, prime + MAX + 1, true);
	fill(sum, sum + MAX + 1, 0);
	prime[0] = prime[1] = false;
	for(int i = 2; i <= MAX; i++) {
		sum[i] = sum[i - 1];
		if(prime[i]) {
			sum[i]++;
			for(int j = 2 * i; j <= MAX; j += i)
				prime[j] = false;
		}
	}
#if 0
	for(int i = 1; i < 20; i++) {
		cout << i << " " << sum[i] << endl;
	}
#endif
	for(int n; cin >> n;)
		cout << sum[n] << endl;
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstring>
#include <algorithm>
#include <limits.h>
#include <cmath>
#include <time.h>
#define REP(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define SQR(X) ((X)*(X))

/* Eratosthenes(int prime[],int n)は
nまでの素数をprimeに、2,3,と入れていきます */
/* 実行後arr[i]はiが素数の時1になります */
static ull prime[1000000];
ull Eratosthenes(ull N){
  static ull arr[15000005];
  for(ull i = 0; i < N; i++){
    arr[i] = 1;
  }
  for(ull i = 2; i < sqrt((double)N); i++){
    if(arr[i]){
      for(ull j = 0; i * (j + 2) < N; j++){
        arr[i *(j + 2)] = 0;
      }
    }
  }
  ull a = 0;
  for(ull i = 2; i < N; i++){
    if(arr[i]){
      prime[a++] = i;
    }
  }
  return a;
}

int test = 0;
/* ここからが本編 */
int main(void)
{
  int i,j,k,l;
  int rep = 100000;
  int n;
  while(cin >> n) {
    cout << Eratosthenes(n+1) << endl;
  }
  return 0;
}

C++: include <iostream>
using namespace std;
 
int main(){
   bool is_prime[1000000];
   is_prime[0]=is_prime[1]=false;
   for(int i=2;i<1000000;i++)
      is_prime[i]=true;
   for(int i=2;i*i<1000000;i++){
      if(is_prime[i]){
         for(int j=i*i;j<1000000;j+=i){
            is_prime[j]=false;
         }
      }
   }
   int n[1000000];
   int count=0;
   for(int i=0;i<1000000;i++){
      if(is_prime[i])
         count++;
      n[i]=count;
   }
   while(true){
      int x;
      cin >> x;
      if(cin.eof())
         break;
      cout << n[x] << endl;
   }
    
   return 0;
}

C++: #include <iostream>

using namespace std;

int isprime(int x){
	if(x < 2){
		return false;
	}else if(x==2){
		return true;
	}else{
		for(int i=3;i<x/2;i=i+2){
			if(x%i==0){
				return false;
			}
		}
		return true;
	}
}

int main(){
	int n;
	while((cin >> n)){
	int a = 0;
	for(int i=2;i<=n;i++){
		if(isprime(i)){
			a++;
		}
	}
	cout << a << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main(){
    int e[30];

    int k = 0;
    while( scanf( "%d",&e[k] ) != EOF )k++;

    for( int i = 0;i < k;i++ ){
        int n = 10;
        int k = 1;
        while( true ){
            if( e[k] % n != 0 ){
                k++;
                n *= 10;
            } else {
                break;
            }
        }
        printf( "%d\n",k );
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 1000005;
bool is_prime[MAX_N];
int n;
int main(int argc, const char * argv[])
{
    while (~scanf("%d", &n)) {
        for (int i = 2; i <= n; i++) is_prime[i] = true;
        //エラストテネスのふるい
        int count = 0;
        for (int i = 2; i <= n; i++) {  //2からnまで確認
            if (is_prime[i]) {  //素数iを発見
                count++;
                for (int j = 2*i; j <= n; j += i) {  //iの倍数を消す
                    is_prime[j] = false;
                }
            }
        }
        printf("%d\n",count);
    }
    
    return 0;
}

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

using namespace std;

int main() {

	int n;
	int *k;
	
	while (cin >> n) {
		int counter = 0;
		k = (int *)malloc(sizeof(int) * n);
		if (k == NULL) {
			exit(0);
		}
		k[0] = 1;
		for (int i = 1; i < n; i++) {
			k[i] = 0;
		}

		for (int i = 1; i < n; i++) {
			if (k[i] == 0) {
				for (int j = 1; j < i; j++) {
					if (k[j] == 0) {
						if ((i+1) % (j+1) == 0) {
							k[i] = 1;
							break;
						}
					}
				}
				if (k[i] == 0) {
					for (int t = 2; t < n/(i+1); t++) {
						k[(i+1)*t-1] = 1;
					}
				}
			}
		}

		for (int i = 0; i < n; i++) {
			if (k[i] == 0) {
				counter++;
			}
		}

		cout << counter << endl;

		free(k);
	}

	return 0;
}