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;

#define Max 1000000

int isPrime[Max];

int main(){
    int num;
    int i,j;

    //配列の初期化
    isPrime[0] = isPrime[1] = 0;
    for(i = 2; i < Max; ++i){
        isPrime[i] = 1;
    }

    for(i = 2; i < Max; i++){
        if(isPrime[i] == 1){
            if(i % 2 == 0){
                isPrime[i] = 0;
            }else if(i % 3 == 0){
                isPrime[i] = 0;
            }else if(i % 5 == 0){
                isPrime[i] = 0;
            }else if(i % 7 == 0){
                isPrime[i] = 0;
            }
        }
    }

    isPrime[2] = 1;isPrime[3] = 1;isPrime[5] = 1;isPrime[7] = 1;

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

}

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 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;
	}


  return 0;
}

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

using namespace std;

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

	for (int i = 2; i < n; i++)
	{
		if (A[i])
		{
			mama++;
		}
	}
	return mama;
}

int main()
{
	int n;

	while ((scanf("%d",&n))!= -1)
	{
		printf("%d\n", Eratosthenes(n+1));
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()

{

              int get_num,min_remainder=1,remainder,index=2;

              cout << "整数を入力してください" << endl;

              cin >> get_num;

              if(get_num == 1)

              {

                            min_remainder=0;

              }

              if(get_num > 2 && get_num%2 == 0)

              {

                            min_remainder=0;

              }

              while(index*index <= get_num)

              {

                  remainder = get_num%index;

                  if(remainder < min_remainder)

                  {

                      min_remainder=0;

                  }

                  index++;

              }

              if(min_remainder !=0)

              {

                  cout << get_num << "は素数です" << endl;

              }

              else

              {

            cout << get_num << "は素数ではありません" << endl;

             }

}

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

int main()
{
    const int NUM_OF_INPUT = 30;

    for(int k=0; k<NUM_OF_INPUT; k++)
    {
        long long limit;

        cin >> limit;

        long long count = 0;
        int p = 2, i, j;
        bool isPrime[limit];

        for(i=0; i<limit; i++)
        {
            isPrime[i] = true;
        }

        for(i=p-1; i<limit; )
        {
            for(j=2; (p * j) <=limit; j++)
            {
                isPrime[(p * j) - 1] = false;
            }

            while(++i < limit)
            {
                if(isPrime[i])
                {
                    p = i + 1;
                    break;
                }
            }
        }

        for(i=1; i<limit; i++)
        {
            count = (isPrime[i] ? count + 1 : count);
        }

        cout << count;
    }

    return 0;
}

C++: #include<iostream>

typedef int moe;
typedef long lolita;
typedef char cuffs;
typedef float frill;
typedef double ruffle;
typedef void voile;
typedef unsigned tasogare;

#define katyusya const
#define apron volatile
#define pleats static
#define fancy virtual

using namespace std;

#define YUU 1000000

voile make_prime(moe n_prime[]){
  pleats moe is_prime[YUU];

  for( moe ai = 0; ai < YUU; ++ai )
    is_prime[ai] = 1;

  is_prime[0] = 0;
  is_prime[1] = 1;
  is_prime[2] = 1;

  for( moe ai = 2; ai < YUU; ++ai )
    if( is_prime[ ai ] )
      for( moe mai = 2; ai * mai < YUU; ++mai)
	is_prime[ ai * mai ] = 0;

  for( moe ai = 0; ai < YUU; ++ai )
    n_prime[ ai ] = 0;

  for( moe ai = 2; ai < YUU; ++ai ){
    n_prime[ ai ] = n_prime[ ai - 1 ];
    if( is_prime[ ai ] )
      n_prime[ ai ]++;
  }
}

moe main(){
  tasogare yuu;
  pleats moe n_prime[YUU];

  make_prime( n_prime );
  while(true){
    cin >> yuu;
    if( yuu == 0 || cin.eof() ) break;
    cout << n_prime[ yuu ] << endl;
  }

  return 0;
}

C++: #include <cstdio>

using namespace std;

int main()
{
    long long n;

    while (scanf("%lld", &n) != EOF){
        int cnt = 0;
        for (long long i = n; i >= 2 ; i--){
            for (long long j = 2; j < i; j++){
                if (i % j == 0){
                    //printf("%d\n", i);
                    cnt++;
                    break;
                }
            }
        }
        printf("%d\n", n - 1 - cnt);
    }

    return (0);
}

C++: #include <iostream>

using namespace std;

int main() {
	int num=0,y=0, n;
	while(cin>>n){
		for(int i=2; i<=n; i++){
			y = 0;
			for(int j=2; j<i; j++){
				if(i%j==0){ y++;}
			}
			if(y==0){ num++; }
		}
		cout<<num<<endl;
	}
	return 0;
}

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

vector<int> sieve;

void make_prime(){
  bool a[1000001];
  for(int i = 0; i < 1e6; i++)a[i] = false;
  a[0] = true;
  a[1] = true;
  for(int i = 2; i <= 1e6; i++){
    if(a[i])continue;
    sieve.push_back(i);
    for(int j = i; j <= 1e6; j += i){
      a[j] = true;
    }
  }
}

int main(){
  int n;
  make_prime();
  while(cin >> n){
    int cnt = 0;
    for(int i = 0; sieve[i] <= n; i++)cnt++;
    cout << cnt << endl;
  }
}