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;

int main()
{
   int n,count=0,m=0,i,j;
   
    while(scanf("%d",&n)!=EOF){
        for(i=2;i<=n;i++){
            for(j=1;j<i;j++){
                if(i%j==0)count++;
            }
            if(count==1)m++;
            count=0;
        }
        printf("%d\n",m);
        m=0;
    }

                return 0;
}

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

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

using namespace std;

constexpr int MAX = 1000000;

int main()
{
    vector<bool> prime_list(MAX, true);
    prime_list.at(0) = false;
    prime_list.at(1) = false;
    for(int i = 2; i * i < MAX; ++i)
    {
        if(!prime_list.at(i))
            continue;
        for(int j = 2; i * j < MAX; ++j)
            prime_list.at(i * j) = false;
    }

    int num;
    int count;
    while(cin >> num)
    {
        count = 0;
        for(int i = 2; i <= num; ++i)
        {
            if(prime_list.at(i))
                count++;
        }
        cout << count << endl;
    }
}

C++: #include <stdio.h>

const int MAX = 999999;
int Prime[MAX];

void makePrimeList(int n) {
  Prime[0] = 1;
  int i, j;
  for (i = 2; i <= n / 2; i++) {
    for (j = 2; i * j <= n; j++) {
      Prime[i * j - 1] = 1;
    }
  }
}

int isPrime(int n) {
  if (Prime[n - 1] == 0) return 1;
  return 0;
}

int main() {
  
  int n, i, cnt, oldMax = 0;
  
  int init;
  for (init = 0; init <= MAX; init++) { Prime[init] = 0; }
  
  while(1) {
    if (scanf("%d", &n) == EOF) break;
    
    if (oldMax < n) {
      makePrimeList(n);
      oldMax = n;
    }
    cnt = 0;
    
    for (i = 1; i <= n; i++) {
      if (isPrime(i) == 1) cnt++;
    }
    
    printf("%d\n", cnt);
  }
  return 0;
}

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

int main(){
	bool prime[MAX_LIST];
	for(int i=0;i<MAX_LIST;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=0;i*i<MAX_LIST;i++){
		if(prime[i]==1){
			for(int j=i*2;j<MAX_LIST;j=j+i){
				prime[j]=0;
			}
		}
	}
	int n;
	while(cin>>n){
		int count=0;
		for(int i=0;i<=n;i++){
			if(prime[i]==1){
				count++;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

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

using namespace std;


int main(int argc, const char * argv[]) {
    // insert code here...
    
    int maxNumber;
    int countPrime=0;
    
    int prime[999999]={0};
    
    prime[0]=-1;
    prime[1]=-1;
    

        for(int i=2; i<1000000;i++){
            for(int j=2; j<i;j++){
                if(i%j==0){
                    prime[i]=-1;
                }
            }
        }
    
    

    while(cin >> maxNumber){
        countPrime=0;
        for(int x=2;x<maxNumber+1;x++){
            if(prime[x]==0){countPrime++;}
        }
        cout << countPrime << endl;
    }


    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

    while(cin >> n){
      prime = 1;
      for(int i=3; i <= n; i++){
        int j = 2;
        while(i%j !=0) j++;
        if(j == i) prime++;
      }
      cout << prime << endl;
    }
    return 0;
}

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

using namespace std;

int A[100];
int Pream(int n)
{
	int kusa = (int)sqrt((double)n);
	int mama = 0;

	for (int i = 0; i < n; i++)
		A[i] = 1;  // ??¨????????°???1????????????
	A[0] = 0;    // 1????´???°??§?????????

	for (int i = 1; i < kusa; i++) {
		if (A[i] == 1)   // prime[i]????´???°??????
		{
			for (int j = (i + 1); (i + 1) * j <= n; j++)
				A[(i + 1) * j - 1] = 0;  // ?´???°????????°????´???°??§?????????
		}
	}
	for (int i = 0; i < n; i++)
		if (A[i] == 1)  // 1????????£???????????????????´???°
			mama++;

	return mama;
}

int main()
{
	int n;
	cin >> n;
	while (n != -1)
	{
		cout << Pream(n) << endl;
		cin >> n;
	}
	return 0;
}

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

int main(){

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

return 0;
}

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

int num,sqt,cnt;

int main()
{
    while(cin>>num)
    {
       sqt=sqrt(num+0.5);
       if(num<=3)cnt=num-1;
       else{cnt=num-2;}
       for(int i=2;i<sqt;i++)
       {
           for(int j=i*2;j<=num;j+=i)
            {
                cnt--;
            }
       }
        cout<<cnt<<endl;
    }
}

C++: #include <iostream>

using namespace std;
 
#define MAX 1000000
 
int main()
{
    int prime[MAX];
    fill(prime, prime + MAX, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i < MAX; i++) {
        if (prime[i]) {
            for (int j = 2*i; j < MAX; j += i) {
                prime[j] = 0;
            }
        }
    }
    
    for (int i = 1; i < MAX; i++) {
	prime[i] = prime[i] + prime[i-1];
    }
    
    int N;
    while (cin >> N) {
	cout << prime[N] << endl;
    }
    return 0;
}

C++: //
//  main.cpp
//  gcd
//
//  Created by Syngnath on 15/12/16.
//  Copyright ? 2015年 Syngnath. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <cstdio>



int primeNumDector(int MAX) {
    int counter;
    bool isPrime[MAX];
    for (int i = 0; i <= MAX;i++)
        isPrime[i] = true;
    
    isPrime[0] = isPrime[1] = 0;
    
    for (int i = 2;i <= (int)sqrt(MAX); i++) {
        if(isPrime[i]) {
            for ( int j = 2*i; j <= MAX;j += i)
                isPrime[j]=0;
        }
    }
    
    for(int i = 2;i <= MAX;i++)
        if(isPrime[i])
            counter++;
    
    return counter;
}


int main()
{
    int n;
    while(scanf("%d",&n) != EOF) {
        int ans = primeNumDector(n);
        printf("%d\n",ans);
    }
}

C++: #include <stdio.h>

#define DATA 30

int main(void)
{
	int h[DATA], k, yakusuu;

	for(int x = 0; x < DATA; x++) {
		k = 0;

		scanf("%d", &h[x]);

		for(int i = 1; i <= h[x]; i++) {
			yakusuu = 0;

			for(int j = 1; j <= i; j++) {
				if(i % j == 0) yakusuu++;
			}

			if(yakusuu == 2) k++;
		}

		printf("%d\n", k);
	}

	return 0;
}