Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

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

constexpr bool divisible(const std::size_t n, const std::size_t m)
{
    return (0 == n % m);
}

std::vector<std::size_t> prime_table = {2};

void make_prime_table(const std::size_t n)
{
    const std::size_t found_last_prime = prime_table.back();
    if(found_last_prime < n)
    {
        std::list<std::size_t> undefined_table;

        for(std::size_t i = found_last_prime + 1; i <= n; ++i)
        {
            undefined_table.push_back(i);
        }

        const std::size_t sn = std::sqrt(n);
        for(std::size_t p = 0; !undefined_table.empty() && p < prime_table.size(); ++p)
        {
            for(auto u = undefined_table.begin(); u != undefined_table.end();)
            {
                if(divisible(*u, prime_table.at(p)))
                {
                    u = undefined_table.erase(u);
                }
                else
                {
                    ++u;
                }
            }
            if(!undefined_table.empty() && found_last_prime <= prime_table.at(p))
            {
                prime_table.push_back(undefined_table.front());
                undefined_table.pop_front();
                if(sn < prime_table.back())
                {
                    break;
                }
            }
        }
        prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
    }
}

std::vector<size_t> prime_acc = {0};

std::size_t prime_size(const std::size_t limit)
{
    if(prime_acc.size() <= limit)
    {
        make_prime_table(limit);
        auto it = prime_table.begin();
        while(prime_acc.size() <= limit)
        {
            it = std::lower_bound(it, prime_table.end(), prime_acc.size());
            if(it != prime_table.end())
            {
                prime_acc.insert(prime_acc.end(), *it - prime_acc.size(), prime_acc.back());
                prime_acc.push_back(prime_acc.back() + 1);
            }
            else
            {
                prime_acc.insert(prime_acc.end(), limit - prime_acc.size() + 1, prime_acc.back());
            }
        }
    }
    return prime_acc.at(limit);
}

int main()
{
    std::size_t n;

    while(std::cin >> n, !std::cin.eof())
    {
        std::cout << prime_size(n) << std::endl;
    }
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,p[10003];
	for(int i=0;i<=10000;++i)p[i]=1;
	p[0]=0;
	p[1]=0;
	for(int i=2;i<=10000,i*i<10000;++i){
		for(int j=2;j<=10000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#pragma warning(disable:4996)

int main()
{
	int DataSet,nCnt,nCnt2,In,Total,Count;

	Total = 0;
	DataSet = 0;

	for (DataSet = 0; DataSet <= 30; DataSet++)
	{
		scanf("%d", &In);
		Total = 1;

		if (In > 2)
		{
			for (nCnt = 3; nCnt <= In; nCnt += 2)
			{
				Count = 0;

				for (nCnt2 = 3; nCnt2 <= sqrt((double)nCnt); nCnt2+=2)
				{
					if (nCnt%nCnt2 == 0)
					{
						if (nCnt != nCnt2)
						{
							Count++;
							break;
						}
					}
				}
				if (Count == 0)
					Total++;
			}
		}

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


	return 0;
}

C++: #include<iostream>
#define N 999999
int p[(N+1)/2];int m[N+1];void k(){int i,j,e=1;for(i=3;i<N+1;i++){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}using namespace std;main(){int n;p[0]=2;m[1]=0;m[2]=1;k();while(cin>>n){cout<<m[n]<<endl;}}

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]=v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]){
        for(long long int j=(long long int)i*(long long int)i;j<MAX;j+=i){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())break;;
      cout << v[a] << endl;
    }
    return 0;
}

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

int main(){
	int n;
	int *prime,i,j;
	int count;
	bool flag;

	while((cin >> n)!= NULL){
		count = 0;
		prime = new int[(int)sqrt(n)+1];
		for(i = 3; i <= n; i+=2){
			flag = true;
			for(j = 0; j < count; j++){
				if(i % prime[j] == 0){
					flag = false;
					break;
				}
			}
			if(flag == true){
				prime[count++] = i;
			}
		}
		if(n > 1)	count++; //2
		cout << count << endl;
		delete prime;
	}
	return 0;
}

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

int CountPrime(int N);
int CheckPrime(int N);
bool IsPrime(int num);

int main()
{
	int N;

	while (std::cin >> N)
	{
		std::cout << CountPrime(N) << std::endl;
	}
}

int CountPrime(int N)
{
	int Counter = 0;

	for (int i = 1; i <= N; i++)
	{
		Counter += CheckPrime(i);
	}

	return Counter;
}

int CheckPrime(int N)
{
	if (IsPrime(N))
		return 1;

	return 0;
}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // ??¶??°????????????????????????


	double sqrtNum = std::sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// ?´???°??§?????????
			return false;
		}
	}

	// ?´???°??§??????
	return true;
}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    long in[30];
    long out[30];
    int n = 0;
    long max = 0;
    while(cin >> in[n]){
        if(max < in[n]){
            max = in[n];
        }
        n++;
    }
    //printf("%d", n);
    
    long p[100000];
    p[0] = 2;
    int m = 1;
    for (int i = 3; i <= max; i += 2) {
        bool prime = true;
        for(int j = 0; j < m; j++){
            if (i % p[j] == 0) {
                prime = false;
            }
            if (i / 3 < p[j]) {
                break;
            }
        }
        if (prime) {
            p[m] = i;
            printf("%ld\n", p[m]);
            m++;
        }
    }
    
    
    for (int i = 0; i < n; i++) {
        int s = 0;
        while (in[i] >= p[s] && p[s] != 0) {
            //printf("in: %ld, p: %ld\n", in[i], p[s]);
            s++;
        }
        out[i] = s;
        printf("%ld\n", out[i]);
    }
    
    return 0;
}

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

int main() {
	int n;

	while (cin >> n) {
		int count = 0;
		bool table[1000001] = { false };
		int upper = sqrt(n);

		table[1] = true;

		for (int i = 1; i <= upper; i++) {
			if (table[i] == false) {
				table[i] = true;
				count++;
				for (int j = i; j <= n; j++) {
					if (j % i == 0) {
						table[j] = true;
					}
				}
			}
		}

		for (int i = 1; i <= n; i++) {
			if (table[i] == false) {
				count++;
			}
		}

		cout << count << '\n';
	}

	return 0;
}