Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

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

using namespace std;

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

	return true;
}

int main()
{
	static int N[31];
	static int C[31];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 2; j <= N[i]; j++)
		{
			if (isprime(j) == true)
			{
				C[i] += 1;
			}
		}
	}

	for (int i = 0; i < 31; i++)
	{
		cout << C[i] << endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e6);
bool p[M];
short cnt[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  cnt[0] = cnt[1] = 0;
  loop(i,2,M){
    cnt[i] = cnt[i-1] + p[i];
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int n;
  while(cin>>n)cout<<cnt[n]<<endl;
}

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

int main()
{
	int n, i, i2;
	int prime[10000];
	for(int i=2; i<= 10000; i++){
		prime[i]=1;
		for(i2 = 2; i2<=sqrt(i); i2++)
		{
			if(i % i2 == 0)
			{
				prime[i] = 0;
				break;
			}
		}
	}
	while(1)
	{
		scanf ("%d",&n);
		if(n==0)
		{
			return 0;
		}
		for(i=n; 1; i--)
		{
			if(prime[i] && prime[i-2])
			{
				printf("%d %d\n",i-2 ,i);
				break;
			}
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

bool a[1000000];

int main()
{
    memset(a, true, sizeof(a));

    for (int i = 2; i < 1000000; i += 1 + (i & 1)) {
        if (!a[i]) continue;
        for (int j = i*2; j < 1000000; j += i) a[j] = false;
    }

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

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

//2,3,5????????°????¨?????????????????????????????¨??????????????????¨??????


int main(void){

	int n,count_num,count_pnum;

	while (cin >> n){
		count_num = 0;
		for (int i = 2; i < n+1; i++){
		
			//2,3,5?????¨????????????
			if (i == 2 || i == 3 || i == 5){ count_num++; }

			if (i % 2 != 0 && i % 3 != 0 && i % 5 != 0){
			//2,3,5??§?????????????????¨???????´???°??§??????????????§?¨?????????????
				count_pnum = 0;
				for (int j = 7; j < i; j++){
					if (i%j != 0)count_pnum++;
				}if (count_pnum == i - 7)count_num++;


			}
		}cout << count_num << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <list>
#include <algorithm>

using namespace std;

int main() {
  int n;
  
  while(!cin.eof()) {
    cin >> n;
    list<int> search_list(n);
    list<int> prime_number;
    while(n!=1) {
      search_list.push_front(n);
      n--;
    }
    while(!search_list.empty()) {
      int m = search_list.front();
      prime_number.push_back(m);
      search_list.pop_front();
      list<int>::iterator it = search_list.begin();
      while(it!=search_list.end()) {
	if((*it % prime_number.front()) == 0){
	  it = search_list.erase(it);
	  continue;
	}
	it++;
      }				   
    }
    cout << prime_number.size()-1 << endl;
  }
}

C++: #include<iostream>
using namespace std;
int main(int argc,char* argv[]){
unsigned x[30];
int count=0;
for(int i=0;i<argc;I++){
cin>>x[i];
}
for(int i=0;i<argc(i++){
for(int j=1;j<x[i];j++){
if(x[i]%j!=0)
count++;
}
cout<<count<<endl;
count=0;
}
return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
        int n;
        int d; //素数を入れるための添字
        bool count; //割りきれるかどうかの判定
        int number[400000]; //素数を入れておく
        number[0] = 2;
        
        
        while(cin >>n != 0){
                d = 0;
                for(int i = 3; i <= n; i++){
                        count = true;
                        for(int j = 0; j <= d; j++){
                                if(i % number[j] == 0){
                                        count = false;
                                }
                        }
                        if(count == true){
                                d++;
                                number[d] = i;
                        }
                }
        cout << d+1 << endl;
        }
}

C++: #include<stdio.h>
int main(){
	int a,b,c,n;
	c=0;
	scanf("%d",&n);
	for(a=1;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<iostream>
#include<cmath>
#include<vector>
using namespace std;

// bool isPrime(unsigned int n);

int main()
{
    int n;
    while(cin>>n){
        vector<int> primeTable;
        if( n==1 ){ cout << "0" << endl; continue; }
        primeTable.push_back(2);
        for(int i=3; i<=n; i++){
            vector<int>::iterator j;
            for(j=primeTable.begin(); j!=primeTable.end(); j++){
                if(!(i%(*j))) break; // i%j!=0
            }
            if( j==primeTable.end() ) primeTable.push_back(i);
        }
        cout << primeTable.size() << endl;
    }
    

    return 0;
}

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

#define rep(i, n) for(int i = 2; i <= n; i ++)

using namespace std;

int main(void){
	for(int n, count = 0; cin >> n; cout << count << endl, count = 0){
		vector<bool> numberList(n + 1);

		rep(i, n) numberList[i] = true;

		for(int i = 2; i * i <= n; i ++) for(int j = i; i * j <= n; j ++) if(numberList[i * j]) numberList[i * j] = false; 
		
		rep(i, n) if(numberList[i]) count ++;
	}

	return 0;
}

C++: #include<bits/stdc++.h>
int main()
{
    long long int low, high, i, flag,c, s ;
    while(scanf("%lld",  &high)!=EOF){
    long long int start = 2;

    c = 0;


    while (start <= high)
    {
        flag = 0;
        s = sqrt(start);
        for(i = 2; i <= s; i++)
        {
            if(start% i == 0)
            {
                flag = 1;
                break;
            }
        }

        if (flag == 0)
        {
              c++;
        }
        start++;

    }
    printf("%lld\n",c);

    }

C++: #include <iostream>
#include <algorithm>
using namespace std;
vector<int> prime;
void init(){
	for(int i=2;i<999999;i++){
		bool isprime=true;
		for(vector::iterator p(prime.begin());p!=prime.end();p++){
			if(i%*p==0){
				isprime=false;
				break;
			}
		}
		if(isprime){
			prime.push_back(i);
		}
	}
}
int main(){
	int n;
	init();
	while(cin>>n){
		cout<<lower_bound(prime.begin(),prime.end(),n)-prime.begin()+1<<endl;
	}
	return 0;
}

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

int main() {
	int n, cnt; 
	while (cin >> n) {
		cnt = 0;
		vector<bool> v(n + 1, true);
		for (int i = 2; i*i <= n; i++) {
			if (v[i]) {
				for (int j = 2 * i; j <= n; j += i) {
					v[j] = false;
				}
			}
		}
			for (int i = 2; i <= n; i++) {
				if (v[i]) cnt++;
			}
		cout << cnt << endl;
	}
	return 0;
}