Go: package main

import (
    "fmt"
    "bufio"
    "os"
    "strconv"
)

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <fstream>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <functional>
#define inf 0x3f3f3f3f
#define inff -30000000
using namespace std;
typedef long long ll;
const int MAXN=1e5+10;
const int MAX=1000000+10;
bool notprime[MAX];
int num=0;
void init(){
    memset(notprime,0,sizeof(notprime));
    for(int i=2;i*i<=MAX;i++){
        if(!notprime[i]){
            for(int j=i*i;j<=MAX;j+=i)
                notprime[j]=1;
        }
    }
}
int main(){
    #ifdef SIYU
    freopen("in.txt","r",stdin);
    #endif // SIYU
    int n;
    init();
    while(cin>>n){
        int ans=0;
        for(int i=2;i<=n;i++){
            if(!notprime[i])
                ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>

using namespace std;

int gcd( int, int );

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

	return true;
}

int main()
{
	int n, count = 0;

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

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

	return 0;
}

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

using namespace std;

int main(){
	int n,i,j,buf,cnt;

	while(cin >> n){
		cnt = 1;

		for(i=3;i<=n;i+=2){
			buf = (int)sqrt((double)i);

			for(j=3;j<=buf;j+=2){
				if((i % j) == 0){
					cnt--;
					break;
				}
			}

			cnt++;
		}

		cout << cnt << endl;
	}

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int N[3]; int C[3] = { 0, 0, 0 };

	int PRIME[168];

	int cnt = 1;

	PRIME[0] = 2;

	for (int i = 3; i <= 999; i++)
	{
		for (int j = 2; j <= (i - 1); j++)
		{
			if (i % j == 0)
			{
				goto Exit1;
			}
		}
		
		PRIME[cnt] = i; cnt++;

	Exit1:;
	}

	cin >> N[0] >> N[1] >> N[2];

	for (int i = 0; i < 3; i++)
	{
		for (int j = 2; j <= N[i]; j++)
		{
			for (int k = 0; k <= 167; k++)
			{
				if (j % PRIME[k] == 0 && j != PRIME[k])
				{
					goto Exit2;
				}
			}

			C[i]++;

		Exit2:;
		}
	}

	cout << C[0] << endl << C[1] << endl << C[2] << endl;

	return 0;
}

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

void setPrime(int *prime , int num)
{
	vector<int> prime_num;
	prime_num.push_back(2);
	prime[2] = 1;
	for (int i = 3; i < num; i++) {
		bool isPrime = true;
		for (int j = 0; j < prime_num.size(); j++) {
			if (i%prime_num[j] == 0)
				isPrime = false;
		}
		if (isPrime) {
			prime_num.push_back(i);
		}
		prime[i] == prime_num.size();
	}
}

int main()
{
	int prime[1000000];
	setPrime(prime, 1000000);
	int n;
	while (cin >> n) {
		cout << prime[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
#define MAX_N 100001
int main(){
	int n;
	while(cin >> n){
		vector<int> vec;
		vector<int>::iterator it =vec.begin();
		for(int i=2;i<=n;i++){
			int flag=0;
			it =vec.begin();
			while(it!= vec.end()){
				if(i% *it==0){
					flag=1;
					break;
				}
				it++;
			}
			if(!flag)vec.push_back(i);
		}
		it =vec.begin();
		//while(it!= vec.end()){
		//	cout<<*it<<endl;
		//	it++;
		//}
		cout << vec.size()<<endl;
	}
}

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

using namespace std;

vector<int> PrimeNumber;
int p = 0;

int f(int x){
	if (x == 2) {
		PrimeNumber.push_back(x);
		return 1;
	}
	for (int i = 0; i < PrimeNumber.size(); i++){
		if (x%PrimeNumber[i] == 0) return 0;
	}
	PrimeNumber.push_back(x);
	return 1;
}

int main(){
	long int n;
	int ans = 0;
	while (cin >> n){
		ans = 0;
		PrimeNumber.clear();
		for (int i = 2; i <= n; i++){
			ans += f(i);
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>

using namespace std;

bool array[1000000];
int main()
{
	int n;
	array[0] = true;
	array[1] = true;
	n = 1000000;
	for (int i = 2; i < n; i++) {
		if (array[i] == false){
			for (int j = i * 2; j < n; j += i) {
				array[j] = true;
			}
		}
	}
	while (cin >> n){
		int pri = 0;
		for (int i = 0; i <= n; i++){
			if (array[i] == false) {
				pri++;
			}
		}
		cout << pri << endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n=0,m=0,o=0,f=0,c=0;

	while(cin>>n){
		c=0;

	for(o=2;o<=n;o++)
	{	f=0;
				cout<<o<<"o"<<endl;
		for(m=2;m<o;m++){
			if(o%m == 0){f++;
			
				cout<<m<<" m "<<endl;}

		};
		if(f==0){c++;};

	};
	cout<<c<<endl;
	};
 return 0;

}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n;
	bool f;
	while(1){
	vector<int> array;
	cin >> n;
	if(cin.eof())return 0;
	for(int i=2;i<=n;i++){
		f=true;
		for(int j=0;j<array.size();j++)
		if(!(i%array[j])){
		f=false;
		continue;
	}
		if(f==true)array.push_back(i);
	}
	cout << array.size() << endl;
	}
}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[100005];
void solve()
{
	REP(i, 100005)prime[i] = true;
	prime[0] = prime[1] = false;
	FOR(i, 2, (int)sqrt(100005))
	{
		if (prime[i] == true)
		{
			FOR(j, 2, (int)sqrt(100005)){
				if (prime[i*j] == true)prime[i*j] = false;
			}
		}
	}
}

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

		int ans = 0;

		solve();
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

using namespace std;

const int N = 10000002;

int main(){
  int n,count = 0 ;
  vector<int> v(N,1) ;
  v[0] = 0, v[1] = 0;
  for(size_t i = 2; i < N-1;++i){
    if(v[i] == 1){
      for(size_t j = i*2; j < N-1;j+=i){
          v[j] = 0 ;
      }
    }
  }
  while(cin >> n){
    count = 0 ;
    for(size_t i = 2; i <= n;++i){
      if(v[i] == 1){
        ++count ;
      }
    }
    cout << count << endl;
  }
  return 0 ;
}

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

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

int main()
{
    int ans;
    int buff;
    while(cin >> buff);
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}