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<stdio.h>
int main(){
			int a,b,c,n;

	while(scanf("%d",&n) != EOF){
		c=0;
			for(a=2;a<=n;a++){
				for(b=2;b<=n;b++){
					if(a%b==0&&a!=b){
						break;
					}else if(a%b==0&&a==b){
						c++;
					}else{
					}
				}
			}
			printf("%d\n",c);
	}
	return 0;
}

C++: #include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#include<ctype.h>

#include<iostream>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<vector>

using namespace std;

#define Max(a,b) (a)>(b)?(a):(b);
#define Min(a,b) (a)<(b)?(a):(b);
int prime[1000000];
int main()
{
    prime[0]=1;
    prime[1]=1;
    long long i,j;
    for(i=2;i*i<=1000000;i++){
        if(prime[i]==0)
        for(j=i+i;j<=1000000;j+=i){
            prime[j]=1;
        }
    }

    int cnt = 0;
    for(i=2; i<1000000;i++){
        if(prime[i]==0)prime[i]= ++cnt;
        else prime[i]= cnt;
    }

    int n;
    while(scanf("%d",&n)==1)
    {
        if(n<2){cout<<"0"<<endl; continue;}

        cout<<prime[n]<<endl;
    }

    return 0;
}

C++: #include <iostream>
#include <cmath>

using namespace std;

long* primes(long high)
{
  long* p = new long[high];
  for (int i = 0; i < high; i++) {
    p[i] = 0;
  }

  long max = ceil(sqrt(high));
  for (int i = 2; i <= max; i++) {
    if (p[i - 1] == -1) continue;

    int count = 2;
    while (i * count <= high) {
      p[i * count - 1] = -1;
      count++;
    }
  }

  for (int i = 1; i < high; i++) {
    if (p[i] == -1) {
      p[i] = p[i - 1];
    } else {
      p[i] = p[i - 1] + 1;
    }
  }
  
  return p;
}

int main(int argc, char const* argv[])
{
  long* p = primes(999999);
  long n;

  while (cin >> n) {
    cout << p[n - 1] << endl;
  }
  return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n , ans = 1;

	cin >> n;

	for(int i = 2; i <= n; i++){
		if(i % 2 != 0 && 9 > i){
			//cout << i << endl;
			ans++;

		}if(i >= 9){
			if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0){
				//cout << i << endl;
				ans++;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

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

int is_it_primeNum(int n)
{
	int a = 1;
	if (n == 0 || n == 1)
		return 0;
	else{ 
		for(int i=2;i<n;i++){
			if (n%i==0){
				a = 0;
				break;}
		}
	}
	return a;
}
int how_much_primeNum(int n)
{
	int ans = 0;
	for(int i=2;i<=n;i++){
		ans += is_it_primeNum(i);
	}
	return ans;
}

int main()
{
	int n;
	while(cin>>n)
		cout << how_much_primeNum(n) << endl;
}

C++: #include<iostream>
#include<vector>
#include<cmath>
using namespace std;
int main(){
  int n,k;
  while(cin>>n){
    int num=0;
    if(n==1)cout<<num<<endl;
    else{
      for(int i=3;i<=n;i+=2){
	k=0;
	for(int j=3;j<=sqrt(i);j+=2){
	  if(i%j==0){
	    k=1;
	    break;
	  }
	}
	if(k==0)num++;
      }
      cout<<num+1<<endl;
    }
  }
  return 0;
}

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

inline bool check(int n)
{
	for (int i = 2; i*i <= n; i++)
	{
		if (n % i == 0) return false;
	}
	return true;
}

int main()
{
	int n[1000000] = {};
	int x;
	bool f;
	
	for (int i = 2; i <= 1000000; i++)
	{
		f = check(i);
		if (f == true) n[i] = n[i - 1] + 1;
		else n[i] = n[i - 1];
	}

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

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

struct Eratosthenes {
	// 1-indexedで検索可能
  vector< bool > prime;
  Eratosthenes(int _size) {
    init(_size);
  }	
	
  void init(int n) {
    prime.resize(n + 1);
    for(int i=0; i<prime.size(); ++i) prime[i] = true;
    prime[0] = prime[1] = false;
    for(int i=2; i*i<=n; i++) {
      if (prime[i]) {
        for (int j=0; i*(j + 2)<n; ++j) {
					prime[i*(j+2)] = false;
				}
      }
    }
  }

	// 整数nを素因数分解して, その要素がいくつあるかを返す
	vector< pair< int, int > > prime_factorize(int n) {
		vector< pair< int, int > > res;
		for (int p=2; p*p<=n; ++p) {
			if (n%p != 0) continue;
			int num = 0;
			while (n%p == 0) ++num, n /= p;
			res.push_back(make_pair(p, num));
		}
		if (n != 1) res.push_back(make_pair(n, 1));
		return res;
	}
};

int main() {
	Eratosthenes e(1010101);
  int n;
	while(scanf("%d",&n) != EOF){
		int ans=0;
		for(int i=1;i<=n;++i){
			if(e.prime[i]) {
				++ans;
			}
		}
		cout<<ans<<endl;
	}
  return 0;
}

C++: #include <iostream>
//#include <vector>
//#include <math.h>
//#include <string>
//#include <cmath>

int main(void);
int count_prime_number(int n);

int main(){
	int n;
	int cnt = 0;
	int result[30];

	//while (cnt < 3){
		//std::cin >> n;
	while (std::cin >> n){
		result[cnt] = count_prime_number(n);
		cnt++;
	}

	for (int i = 0; i < cnt; i++){
		std::cout << result[i] << std::endl;
	}

	//while (1);
	return 0;
}


//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
	int rtn = 0;

	//2だけ個別チェック
	if (n >= 2){
		rtn++;
	}

	for (int i = 3; i <= n; i+= 2)
	{
		bool is_prime_num = true;
		for (int j = 3; j <= sqrt(i); j+= 2)		//ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
		{
			if (i % j == 0)
			{
				is_prime_num = false;
				break;
			}
		}

		if (is_prime_num){
			rtn++;

			//デバッグ
			//std::cout << i << std::endl;
		}
	}

	return rtn;
}

C++: #include<iostream>
#include<string.h>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int n,cnt=0,ans,sosu[100003]={0};
	
	for(int i=2;i<100002;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0)flag=false;
		}
		/*if(flag){
		cnt++;
		sosu[i]=cnt;
		}*/
		sosu[i]=(flag)? cnt++ : cnt;		
	}
	//for(int i=0;i<30;i++)cout<<sosu[i]<<" ";
	while(cin>>n){
	cout<<sosu[n]<<endl;
	}
    return 0;
}

C++: #include<stdio.h>
bool b[1000000];

int main(void)
{
    int a,n,i;
    int count=0;
    int f=1;

    for(i=3;i<1000000;i+=2){
        f=1;
        for(a=2;a*a<=i;a++){
            if(i%a == 0){
                f=0;
                break;

            }
        }
        if(f==1){
            b[i]=1;
        }
    }
    b[2]=1;

    while(scanf("%d",&n)!=EOF){
        for(i = 0; i <= n; i++){
            if(b[i]==1)count++;
        }

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

C++: #include <stdio.h>

int main()
{
    unsigned long long int isprime ,n,i,x,z,sum=0;
    scanf("%llu",&x);
    for(n=2;n<=x;n++)
    {
        if(n==2)
        {
            sum++;
        }
        else
        {
            isprime=0;

            for(i=2;i<n;i++)
            {
                if(n%i==0)
                {
                    isprime=1;
                    break;
                }
            }
         }
        if(isprime == 0)
        {
            sum++;
        }
    }
    printf("%llu\n",sum);
    return 0;
}