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 <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int count = 0;
	/*int m = 2, n = 0, num;

	cin >> num;

	int *data = new int[num + 1];
	int *result = new int[num + 1];

	data[0] = 0;
	data[1] = 0;

	do
	{
		for (i = 2 * m; i < num + 1; i += m)
		{

		}
	}
	while
	{

	}*/
	const int N = 9999999;
	int n;
	std::vector<bool> isPrime(N + 1, true);    // ?´???°????????°?????¨??¨ON???

	while (cin >> n)
	{
		count = 0;
		for (int i = 2; i < n; ++i) {
			if (isPrime[i])
			{
				count++;

				for (int k = i + i; k <= n; k += i)
					isPrime[k] = false;      // ?´???°????????°????´???°????????°?????¨???OFF???
			}
		}

		cout << count << endl;
	}
	
	return 0;






	
}

C++: #include<stdio.h>

int isPrime(int n){
  int i;
  if(n<2)return 0;
  if(n==2)return 1;
  if(n%2==0)return 0;
  for(i=3;i<=n/i;i+=2)
    if(n%i==0)
      return 0;
  return 1;
}

int main(){
  int a;
  while(scanf("%d",&a)!=EOF){
    int i,ans=0;
    for(i=0;i<=a;i++){
      if(isPrime(i))ans++;
    }
    printf("%d\n",ans);
  }
  return 0;
}

C++: #include <iostream>

using namespace std;
int ns[1000000];
int main()
{
    int n;
    while(cin>>n)
    {
        fill(ns,ns+1000000,true);
        ns[1]=false;
        int cnt=0;
        for(int i=2;i<=n;++i){
            if(ns[i])cnt++;
            for(int j=0;j*i<=n;++j){
                ns[i*j]=false;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}

C++: #include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];int mk();using namespace std;int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();while(cin>>n){cout<<m[n]<<'\n';}return 0;}int mk(){int i,j,e=1;for(i=3;i<N;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}

C++: #include<iostream>
#include<algorithm>
using namespace std;
#define MAX 100000
int p[MAX+1];
void f(){
	int n=0;
	for(int i=2;i<=MAX;i++){
		if(p[i]==0){
			p[i] = ++n;
			for(int j=2;j*i<=MAX;j++)
				p[j*i] = -1;
		}
		else p[i] = n;
	}
} 
int main(){
	int n;
	f();
	while(cin>>n){	
		cout<<p[n]<<endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main()
{
	bool *sosu;
	int *ans,now,n;

	sosu = new bool[1000000];
	ans = new int[1000000];

	for(int i = 0; i < 1000000; i++){
		sosu[i] = true;
	}
	sosu[0] = sosu[1] = false;
	for(int i = 0; i < 1000000; i++){
		if(sosu[i] == true){
			for(int j = 2; j*i < 1000000; j++){
				sosu[j*i] = false;
			}
		}
	}
	now = 0;
	for(int i = 0; i < 1000000; i++){
		if(sosu[i] == true)
			now++;
		ans[i] = now;
	}

	while(scanf("%d",&n) != EOF){
		printf("%d\n",ans[n]);
	}

	return 0;
}

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};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int 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;
}

signed main(){
  int n;
  while(cin>>n&&n){
    if(n==1){cout<<0<<en; RE;}
    int ans=0;
    for(int i=2; i<=n; i++){
      if(isprime(i)) ans++;
    }
    cout<<ans<<en;
  }
}

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

bool is_SPRP(uint32_t n, uint32_t a) {
  uint32_t d = n - 1, s = 0;
  while ((d & 1) == 0) {
    ++s;
    d >>= 1;
  }
  uint64_t cur = 1, pw = d;
  while (pw) {
    if (pw & 1) {
      cur = (cur * a) % n;
    }
    a = ((uint64_t)a * a) % n;
    pw >>= 1;
  }
  if (cur == 1) {
    return true;
  }
  for (uint32_t r = 0; r < s; r++) {
    if (cur == n - 1) {
      return true;
    }
    cur = (cur * cur) % n;
  }
  return false;
}

bool is_prime(uint32_t x) {
  if (x <= 1) return false;
  if (x < 1ULL << 32) {
    uint32_t bases[] = {2, 7, 61};
    for (uint32_t i = 0; i < sizeof(bases) / sizeof(bases[0]); ++i) {
      if (x != bases[i] && !is_SPRP(x, bases[i])) {
        return false;
      }
    }
    return true;
  }
}

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (is_prime(i)) ans++;
    }
    cout << ans << endl;
  }
}

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

int main() {
int b[1000000];
for (int k=0;k<1000001;k++){
	b[k]=0;
}
for (int p=2;p<1000001;p++){
int i,a=0 ;
	i=2;
	while(i<p){
		if(p%i==0){
			break;
	}i=i+1;
	}
	if (i==p){
		a=1;
	}
	b[p]=a;
}
int c[1000000];
for (int l=0;l<1000001;l++){
	c[l+1]=c[l]+b[l+1];
}
int r;
while(cin>>r){
	cout<<c[r]<<endl;
}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    if(num == 1) return false;
    if(num == 2) return true;
    if(num % 2 == 0) return false;
    max = ceil(sqrt(num));

    for(c=3; c < max+1; c+=2)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans =0;
    int c;
    int buff;
    vector<int> prime;
    for(c=1;c<=999999;c++)
    {
        if(isprime(c)) ans++;
        prime.push_back(ans);
    }
    cout << prime[0] << endl;
    while(cin >> buff)
    {
        cout << prime[buff -1] << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool flg[1000000];
int main(void){
	int n;
	int i,j;
	int cnt=0;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		fill(flg,flg+n+1,0);
		for(i=2;i*i<=n;i++){
			//cout<<"I="<<i<<endl;
			for(j=2;i*j<=n;j++){
				//cout<<"J="<<j<<endl;
				flg[i*j]=1;
			}
		}
		cnt=0;
		for(i=2;i<=n;i++)	if(flg[i]==0)	cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include<iostream>
int fact(int x){
	int sx=0,sy=0;
	for(int i=2;i<x+1;i++){
		if(x%i==0)sx++,sy+=i;
	}
	if(sx==1)return x;
	else return sy+1;
}
int main(){
	int a=0;
	while(std::cin>>a){
		int n=0;
		for(int i=2;i<a+1;i++){
			if(i==fact(i))n++;
		}
		std::cout<<n<<std::endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int N;
	int count;

	while(cin>>N)
	{
		count=0;
		for(int i=2;i<=N;i++)
		{
			int f=0;
			for(int j=1;j<i;j++)
				if((i%j)==0)
					f++;
			if(f<2)count++;
		}

		cout<<count<<endl;
	}

	return 0;
}