Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

C++: #include<iostream>
#include<stack>
#include<math.h>
using namespace std;
int dp[100000000];
void shokika();
int main() {
	int n, ans = 0, i, count = 0, count2 = 0, insq;
	double sq;
	bool bo=false;
	shokika();
	while (cin >> n) {
		for (i = 2; i <= n; i++) {
			if (dp[i] == 1) {
				ans++;
				bo = true;
			}
			else {
				bo = false;
			}
			//sq = sqrt(i);
			//insq = (int)sq;
			for (int j = 2; j <= i; j++) {
				if (bo == true) {
					break;
				}
				else if (bo == false && dp[i] != -1) {
					count = 0;
					break;
				}
				/*
				if ( (i % 2 == 0 || i % 3 == 0 || i % 5 == 0 || i % 7 == 0 || i % 11 == 0)) {
					count = 0;
					break;

				}
				*/
				if (i%j == 0) {
					count++;
				}
				if (count >= 2) {
					break;
				}
				/*
				else {
					cout << i <<" "<<count<< endl;
				}
				*/

			}
			if (bo == true) {
				continue;
			}
			if (dp[i] == -1) {
				dp[i] = count;
			}
			if (dp[i] == 1) {
				//	cout << i << endl;
				ans++;
			}
			count = 0;
		}
		cout << ans << endl;
		ans = 0;
	}

	/*
	for (int i = 1; i < n; i++) {
		if (n%i == 0) {
			count++;
		}
		if (count >= 2) {
			count = 0;
			continue;
		}
		else  {
			ans++;
		}
	}
	cout << ans << endl;
	ans = 0;
}
*/
	return 0;
}
void shokika() {
	for (int i = 0; i < 100000000; i++) {
		dp[i] = -1;
	}
	return;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000000;
bool is_prime[SIZE];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin());

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <vector>
#include <map>

int main() {
	int a;
	while (std::cin >> a) {
		int nSum = 0;
		for (int i = 2;i <= a;i++) {
			int flag = 0;
		for (int j = 2;j < i;j++) {
			if (i%j == 0) {
				flag = 1;
				break;
			}
		}
		if (flag == 0) {
			nSum += 1;
		}
	}
		std::cout << nSum << std::endl;
	}
	return 0;
}

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

int Era(int N) {
	int prime_num = 0;
	int* array = new int[N + 1];
	for (int i = 2; i < N + 1; i++) {
		array[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (array[i]) {
			for (int j = 0; i*(j + 2) <= N; j++) {
				array[i*(j + 2)] = 0;
			}
		}
	}
	for (int i = 2; i < N + 1; i++) {
		if (array[i])prime_num++;
	}
	return prime_num;
}

int main() {
	int num;
	while (cin >> num) {
		cout << Era(num) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
cin >> n;
vector<int> prime;
prime.push_back(2);//ôðÈ­½ß2ÍÅÉüêÄ¨­
bool flag;
for(int x=3;x<=n;x+=2){
flag=true;
for(int y=0;prime[y]*prime[y]<=x;y++){
if(!(x%prime[y])){
flag=!flag;
break;
}
}
if(flag)prime.push_back(x);
}
cout << prime.size() << endl;
return 0;
}

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

int main()
{
	vector<int> pcount;
	int prime[10000];
	int j, k, x, num,count=0;
	while (cin >> num){
		prime[0] += 2;
		x = 1;
		k = 1;
		while (prime[k-1] <= num)
		{
			x += 2;
			j = 0;
			while (j < k && x % prime[j] != 0)j++;
			if (j == k)
			{
				prime[k++];
				count++;
			}
		}
		pcount.push_back(count);
		count = 0;
		break;
	}
	for (int i = 0; i < pcount.size(); i++)
	{
		cout << pcount[i] << endl;
	}
	return 0;
}

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

int main(void) { 
	int A[1000000];
	for(int i = 0; i < 1000000; i++){
		A[i] = 1;
	}
	A[0] = A[1] = 0;
	for(int i = 2; i < 1000; i++){
	    if(A[i] == 1){
    		for(int j = 2; j < 500; j++){
                A[i * j] = 0;
		    }
	    }
	}
	int n;
	while(cin >> n){ 
		int COUNT = 0;
		for(int i = 1; i <= n; i++){
            COUNT += A[i];
		}
		cout << COUNT << endl;
	}
	return 0; 
}