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++: int main() {
	bool isPrime[1000000] = {true};

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

	isPrime[1] = false;
	for (int i = 2; i < 1000000; i++) {
		if (!isPrime[i])
			continue;

		if (isPrime[i]) {
			int k = 2*i;
			while (k < 1000000) {
				isPrime[k] = false;
				k += i;
			}
		}
	}

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

	return 0;
}

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

bool prime(int a) {
	for (int b = 3;; b += 2) {
		if (a%b == 0)return false;
		if ((b + 1)*(b + 1) > a)return true;
	}
}
int main() {
	while (1) {
		int s = 0;
		int a;
		cin >> a;
		if (cin.fail())break;
		if (a > 1)s++;
		if (a > 2)s++;
		for (int b = 5; b <= a; b+=2) {
			if (prime(b))s++;
		}
		cout << s << endl;
	}
}

C++: #include <iostream>
using namespace std;
int main() {
	int n, count = 0;
	while(cin >> n) {
		for(int i = 2; i <= n; i++) {
			for(int j = 2; j < i; j++) {
				if(i % j == 0) {
					count--;
					break;
				}
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

bool flag[10000001];

int main(){
	int n = 0, ans = 0;
	
	for (int i = 0; i <= 1000000; i++){
		if (i <= 1) flag[i] = false;
		else flag[i] = true;
	}
	for (int i = 2; i <= 1001; i++){
		if(flag[i] == true){
			for(int j = i * 2; j <= 1000000; j += i){
				flag[j] = false;
			}
		}
	}
	while(cin >> n){
		ans = 0;
		for(int i = 0; i <= n; i++){
			if(flag[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
 }

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

using namespace std;

int main()
{
    vector<int> ans(0);
    bool p[999999]; for (int i=0; i<999999; i++) p[i]=true;
    p[1]=false;
    int sum=0, n;
    for (int i=2; i<998; i++)
    {
        for (int j=i+i; j<=999999; j+=i) p[j]=false;
    }
    while (cin>>n)
    {
        for (int i=1; i<=n; i++) if (p[i]) sum++;
        ans.push_back(sum);
        sum=0;
    }
    for (int i=0; i<ans.size(); i++) cout<<ans[i]<<'\n';
    return 0;
}

C++: #include <stdio.h>
#include <math.h>
#include <time.h>

int whether(int num);
int count(int num);

int main(){
	int n;
	int a;
	clock_t c, d;

	while(1){
		if(scanf("%d",&n) == -1) break;
		a = count(n);
		printf("%d\n",a); 
}

	return 0;
}

int whether(int num){
	int s=sqrt(num);
	int i;
	for(i=3; i<=s; i+=2){ if(num%i==0) return 0; }

	return 1;
}

int count(int num){
	int a=1;
	int i;
	if(num <2){ return 0; }
	for(i=3; i<=num; i+=2){
		a += whether(i);
	}

	return a;
}

C++: #include <iostream>

int main(void){
	int num;
	while(std::cin >> num){
		int count = 1;
		int Prime_C = 2; //2,3
		while((6*count+1) <= num){
			++count;
		}
		Prime_C += 2*(count-1);
		if ((6*count-1) <= num){
			++Prime_C;
		}
		if (num == 2){
			Prime_C = 1;
		}
		std::cout << Prime_C << std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring> 
using namespace std;
bool a[10000000];
int main()
{
	int n;
	while(cin>>n)
	{	
		int js=0;
		for (int i=2;i<=n;i++)
		  if (!a[i]) {js++;for (int j=i+i;j<=n;j+=i) a[j]=true;}
		cout<<js<<endl;   
	}
}

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

int main(){
int n;
vector<int> a;
  while(cin << n){
  a.push_back(n);
  }
for(int i=0;i<a.size();i++){
  int k = 0;
  for(int j=2;j<a[i];j++){
    if(a[i]%j == 0 ) k++;
	}
  cout << k ;
 }
}

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

int main(int argc, const char * argv[])
{
    int count=0;
    int i=1;
    int n=1;
    int number;
    // insert code here...
    while (cin >> number, number != EOF){
        while (n <= number){
            if(n == 1) {n++; continue;}
            while (i <= n) {
                if(i == 1) {i++; continue;}
                if(i == n) count++;
                if(n % i == 0) break;
                i++;
            }
            n++;
            i=1;
        }
        i=1;
        n=1;
        cout << count << endl;
        count = 0;
    }
    
    return 0;
}

C++: #include <stdio.h>
int prime[1000001];
int main(){
  int i, k, n,cnt = 0;
  for(i = 2; i <= 1000000; i++){
    prime[i] = 1;
  }
  for(i = 2; i*i <= 1000000; i++){
    if(prime[i]){
      for(k = 2 * i; k <= 1000000; k += i){
        prime[k] = 0;
      }
    }
  }
  while(1){ 
    scanf("%d", &n);
    if(n == 0) break;
    for(i = 2; i <= n; i++){
      if(prime[i] == 1){
        cnt++;
      }
    }
    printf("%d\n",cnt);
    cnt = 0;
  }
  return 0;
}

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

int main(){
	bool x[1000000];
	int cou, num;
	
	while(cin >>num){
		cou = 0;
		for(int i = 2; i <= num; i++){
			x[i] = true;
		}
		for(int i = 2; i <= sqrt(num); i++){
			if(x[i]){
				for(int j = (i * 2); j <= num; j += i){
					x[j] = false;
				}
			}
		}
		
		for(int i = 0; i <= num; i++){
			if(x[i]){
				cou++;
			}
		}
		
		cout <<cou<<endl;
	}
	
	return 0;
}

C++: #include<iostream>
using namespace std;
int d[1000000]={};
int main(){
	int n;
	for(int i=2;i<1000000;i++){
		if(d[i]==0){
			for(int j=2;i*j<1000000;j++){
					d[i*j]=1;
			}
		}
	}
	int ans;
	while(cin>>n,n){
		ans=0;
		for(int i=2;i<=n;i++){
			if(d[i]==0)
			ans++;
		}
		cout<<ans<<endl;;
	}
	return 0;
}

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

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

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

bool isPrime(int x) {
    if (x==2) {
        return true;
    }
    if (x<2 || x%2==0) {
        return false;
    }
    int i=3;
    while (i*i<=x) {
        if (x%i==0) {
            return false;
        }
        i+=2;
    }
    /*for (int i=3; i*i<=x; i+=2) {
     if (x%i==0) {
     return false;
     }
     }*/
    return true;
}
int main() {
    int n;
    int cnt;
    while (cin >> n) {
        cnt=0;
        for (int i=0; i<=n; i++) {
            if (isPrime(i)) {
                cnt++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

C++: #include<stdio.h>
int main(void)
{
	int a,x,i;
	while((scanf("%d",&a))!=EOF){
		x=0;
		for(i=2;i<a+1;i++){
			if(i%2!=0&&i%3!=0&&i%5!=0&&i%7!=0){
				x++;
			}
			else if(i==2||i==3||i==5||i==7){
				x++;
			}
		}
		printf("%d\n",x);
	}
	return 0;
}