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 <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

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

bool prime[1000005]={true};

signed main(){
  int n;
  while(cin>>n){
    if(n==1){cout<<0<<en; RE;}
    for(int i=2; i<=n; i++) prime[i]=true;
    int ans=0;
    for(int i=2; i<=n; i++){
      if(isprime(i)&&prime[i]) {
        ans++;
        for(int j=2*i; j<=n; j+=i) prime[j]=false;
      }
    }
    cout<<ans<<en;
  }
}

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

int prime[1000010];
bool is_prime[1000010];

void seive(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;
		}
	}
}
	
int main() {
	int n;
	
	seive(999999);
	
	while(cin>>n){
		int sum=0;
		
		for(int i=0;i<=n;i++)
		if(is_prime[i])
		sum++;
		
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
/*
int main(){
	
	int i,j;
	bool n[30]={false};
	for(j=0;j<28;j++){
	cin>>n[j];
	n[j]=true;
	}
	for(i=0;i<30;i++){
		if(n[i]==false){
		cout<<i<<endl;
		}
	}

return 0;
}
*/
int main(){
	int a[30],b[28];
	for(int i=1;i<=30;i++){
		a[i-1]=i;
	}
	for(int i=0;i<28;i++){
		cin>>b[i];
	}
	sort(b,b+28);
	int c[2]={0},j=-1,k=-1;
	for(int i=0;i<28;i++){
		j++;
		if(a[i]!=b[j]){
			k++;
			c[k]=a[i];
			j--;
		}
		if(j==27){
			break;
		}
	}
	if(c[0]==0){
		c[0]=29;
	}
	if(c[1]==0){
		c[1]=30;
	}
	cout<<c[0]<<endl<<c[1]<<endl;
	return 0;
}

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

int main(){
	int n,w=0;
	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){
				w++;
			}
		}
	}
	cout << w;	
	return 0;
}

C++: //============================================================================
// Name        : desk.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include<stdio.h>
#include<iostream>
using namespace std;
int main(){

 int n=0,f=0,P=0;

 while(scanf("%d",&n)!=EOF){

 for(int i=2;i<n;i++){

	 if(n%i==0){
		f=1;
		}

 }

 if(f==0){
	 P++;
 }
 
 }
 cout<<P<<endl;
  return 0;
}

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

int main(){
	int a;
	while(cin>>a){
		int ans = 1;
		for(int i = 2; i <= a/i; i++){
			ans += i + a/i;
			if(a == i*i) ans -= i;
		}
		if(ans == 1) cout << a << endl;
	}
	return 0;
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (i != 3 && i % 3 == 0)	continue;
		if (i != 5 && i % 5 == 0)	continue;
		if (i != 7 && i % 7 == 0)	continue;
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in > 2)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in, count500000 = PrimeNumber(500000, 3);

	while (cin >> in, !cin.eof()){
		if (in <= 500000)
			cout << PrimeNumber(in, 3) << endl;
		else
			cout << count500000 + PrimeNumber(in, 500001) << endl;
	}
}

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

using namespace std;

int prime(int n) {
  int i, j, r;
  
  if (n < 2) return 0;
  vector<int> primes(n);

  for (i = 2; i < n; i++)
    primes[i] = i;
  for (i = 2; i*i < n; i++) {
    if (primes[i])
      for (j = i*i; j < n; j += i)
        primes[j] = 0;
  }
  for (i = 2, r = 0; i < n; i++)
    if (primes[i]) r++;
  return r;
}

int main() {
  int n;
  while(cin >> n)
    cout << prime(n) << endl;
  return 0;
}

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

int check(int x,int y,int z,int w){

}

int main(){
	int n;
	while(cin >> n){
		vector<int> prim;
		prim.push_back(2);
		for(int i=3;i<=n;i++){
			bool fl=false;
			for(int j=0;j<prim.size();j++){
				if(i%prim[j]==0){
					fl = true;
					break;
				}
			}
			if(fl==false) prim.push_back(i);
		}
		cout << prim.size() << endl;
	}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <string>
#include <map>
#include <functional>
#include <cmath>
#include <cstdio>
using namespace std;

#define PI 4*atan(1);

vector<int> a;
void func(int n){

  for(int i = 0; i <= n; i++){
    a.push_back(1);
  }
  for(int i = 2; i * i <= n; i++){
    if(a[i]){
      for(int j = 2; i * j <= n; j++){
        a[i * j] = 0;
      }
    }
  }
  int cnt = 0;
  for(int i = 2; i <= n; i++){
    if(a[i]){
      cnt++;
    }
  }
  cout << cnt << endl;
}

int main(){
  int n;
  while(cin >> n){
    func(n);
  }
}

C++: #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> v;
    v.resize(n + 1);
    fill(v.begin(), v.end(), 1);
    v[0] = 0;
    v[1] = 0;
    for (int i = 0; i * i * i < v.size(); ++i) {
      while (v[i] == 0) ++i;
      for (int m = i + 1; m < v.size(); ++m) {
        if (m % i == 0) {
          v[m] = 0;
        }
      }
    }
    cout << accumulate(v.begin(), v.end(), 0) << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int a,i;
for(;;){
cin>>a;
for(int x=2x<a;x++){
if(a%x==0){i++}
cout<<i<<endl;
}
}
return 0;
}

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

int isprime[1000000];

void hurui() {
    isprime[0] = isprime[1] = 0;
    for (int i = 2; i < 1000000; i++) {
        isprime[i] = 1;
    }
    for (int i = 0; i < 1000000; i++) {
        if (isprime[i]) {
            for(int j = i * 2; j < 1000000; j+=i) {
                isprime[j] = 0;
            }
        }
    }
}

int main() {
    hurui();

    int N;
    while(cin >> N) {
        int count = 0;
        for (int i = 0; i <= N; i++) {
            if (isprime[i]) count++;
        }
        cout << count << endl;
    }
    return 0;
}