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<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;
      
      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j*j)
        v[i]=false;
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int data[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				count++;
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
			}
		}

//		printf("%d",data[n]);
	}
	return 0;
}

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

int main() {

    vector<bool> primes (1000000);
    for (int n = 0; n < 1000000; n++) {
        primes[n] = true;
    }
    primes[0] = false;
    primes[1] = false;

    for (int n = 2; n < 1000000; n++) {
        if (primes[n]) {
            for (int k = 2*n; k < 1000000; k = k+n) {
                primes[k] = false;
            }
        }
    }

    int n;
    while (cin >> n) {
        int result = 0;
        for(int i = 0; i <= n; i++) {
            if ( primes[i] ) {
                result += 1;
            }
        }
        cout << result << endl;
    }
     
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
main(){int i,j,n,p[1000000];scanf("%d",&n);for(i=2;i<=n;i++)p[i]=1;for(i=2;i<n;i++)if(p[i])for(j=2;i*j<=n;j++)p[i*j]=0;j=0;for(i=2;i<=n;i++)j+=p[i];printf("%d\n",j);}

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

#define PRIME_FLG_SIZE 1000000
#define PRIME_SUM_SIZE 1000000

bool primeFlg[PRIME_FLG_SIZE]; //[i]テ」ツ?古ァツエツ?ヲツ閉ーテ」ツ?凝」ツ?ゥテ」ツ??」ツ?凝」ツ?ョテァツョツ。テァツ青?
int primeSum[PRIME_SUM_SIZE]; //[0, i]テ」ツ?ョテゥツ鳴禿」ツ?ォテ・ツュツ佚・ツ慊ィテ」ツ?凖」ツつ凝ァツエツ?ヲツ閉ーテ」ツ?ョテヲツ閉ーテ」ツ?ョテァツョツ。テァツ青?

//テ」ツつィテ」ツδゥテ」ツδ暗」ツつケテ」ツδ?」ツδ催」ツつケテ」ツ?ョテ」ツ?オテ」ツつ凝」ツ??
void erato(){
  fill(primeFlg, primeFlg + PRIME_FLG_SIZE, true);
  primeFlg[0] = primeFlg[1] = false;

  for(int i = 2; i * i < PRIME_FLG_SIZE; i++){
    if(!primeFlg[i]) continue;
    for(int j = i * i; j < PRIME_FLG_SIZE; j += i){
      primeFlg[j] = false;
    }
  }

  fill(primeSum, primeSum + PRIME_SUM_SIZE, 0);

  for(int i = 1; i < PRIME_SUM_SIZE; i++){
    bool isPrime = primeFlg[i];
    primeSum[i] = primeSum[i - 1] + (isPrime ? 1 : 0);
  }
}

int main(){
  erato();

  int n;

  while(cin >> n){
    cout << primeSum[n] << endl;
  }
}

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

class PrimeNumbers
{
public:
	vector<int> primeNumbers;

	PrimeNumbers()
	{
		this->createPrimeNumbers();
	}
	
	int answer(int N)
	{
		int result = 0;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(*it <= N)result++;
			else break;
		}
		return result;
	}

	bool checkOf(int n)
	{
		if(n % 2 == 0)return false;

		bool prime = false;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(n == *it)
			{
				prime = true;
				break;
			}
		}
		return prime;
	}

	void createPrimeNumbers()
	{
		int max_number = 100000;
		this->primeNumbers = vector<int>();
		this->primeNumbers.push_back( 2 );
		for(int i = 3; i < max_number; i += 2)
		{
			bool prime = true;
			for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
			{
				if(i % *it == 0)
				{
					prime = false;
					break;
				}
			}
			if(prime)
			{
				this->primeNumbers.push_back(i);
			}
		}
	}

};

int main()
{
	int N;
	PrimeNumbers pn = PrimeNumbers();
	while(cin >> N)
	{
		cout << pn.answer(N) << endl;
	}
	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
using namespace std;
bool dp[1000001] = {};
int sosuu() {
	dp[1] = true;
	for (int i = 2;i <= 1000;++i) {
		if (dp[i] == false) {
			for (int q = 2;q <= 1000000 / i + 1;++q) {
				dp[i*q] = true;
			}
		}
	}
	return 0;
}
int main() {
	sosuu();
	int n = 0;
	while (cin >> n) {
		int count = 0;
		for (int i = 1;i <= n;++i) {
			if (dp[i] == false) count++;
		}
		printf("%d\n", count);
	}
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[n]={0};
		int ans=0;

		for(i=0;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[i]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: #include <iostream>

using namespace std;

int main(){
	int n, x;
	while(cin >> n){
		int x = 0;
		int sum;
	
		for(int i = 1;i <= n;i++){
			sum = 0;
			for(int j = 1; j <= i; j++){
				if( i % j == 0) sum += j;{
					if(sum == i + 1) x++;
				}
			}
		}
		
		cout << x << endl;
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

vector<int> primes;
bool is_prime[1000100];

void search_prime(int n){
	for(int i = 0; i <= n; ++i)
		is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; ++i){
		if(is_prime[i]){
			primes.push_back(i);
			for(int j = i * 2; j <= n; j += i)
				is_prime[j] = false;
		}
	}
}

int main() {
	search_prime(1000050);
	int n;
	while(cin >> n){
		if(n == 0 && n == 1){
			cout << "0" << endl;
		}
		else{
			int idx = lower_bound(primes.begin(), primes.end(), n) - primes.begin();
			if(primes[idx] != n)
				idx--;
			cout << idx << endl;
		}
	}
	return 0;
}

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

using namespace std;

#define REP(a, i, n) for (int i = a; i <= n; ++i)

bool isPrime(int n) {
    if (n == 1) return false;
    if (n == 2) return true;
    if (n % 2 == 0) return false;
    if (n == 3) return true;
    if (n % 3 == 0) return false;

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

//  n よりも小さい素数の数は何個存在するか
int main() {
    int n; // 10000
    scanf("%d", &n);

    int cnt = 0;
    REP(1, i, n) {
        if (isPrime(i)) cnt++;
    }

    printf("%d\n", cnt);

    return 0;
}