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 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 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>
#include <set>
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;
        std::set<std::size_t> undefined_table;

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

        const std::size_t sn = std::sqrt(n);
        for(std::size_t p = 0; prime_table.back() <= sn; ++p)
        {
            for(auto u = undefined_table.begin(); u != undefined_table.end();)
            {
                if(0 == *u % prime_table[p])
                {
                    u = undefined_table.erase(u);
                }
                else
                {
                    ++u;
                }
            }
            if(!undefined_table.empty() && found_last_prime <= prime_table[p])
            {
                // prime_table.push_back(undefined_table.front());
                prime_table.push_back(*undefined_table.begin());
                // undefined_table.pop_front();
                undefined_table.erase(undefined_table.begin());
            }
        }
        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[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() {
  const int max = 1000000;
  int isPrime[max] = {1, 1, 0};
  int i = 2;
  int n, count;

  while(i < max) {
    while(isPrime[i] != 0) {
      i++;
    }
    for(n = 2; n*i < max; n++) {
      isPrime[n*i] = 1;
    }
    i++;
  }

  while(cin >> n) {
    count = 0;
    for(n; n > 0; n--) {
      if(isPrime[n] == 0) count++;
    }
    cout << count << endl;
  }

  return 0;
}

C++: #include <iostream>
#define Even(n) n%2
using namespace std;

void count_Prime(int n);
int Euclid(int n, int m);


int main()
{
	int Data;

	while (cin >> Data)
	{
		count_Prime(Data);
	}

	return 0;
}

void count_Prime(int n)
{
	int counter = 0, euclid = 0, i = 0, j = 0;
	for (i = 2; i <= n; ++i)
	{
		if (Even(i) != 0 || i == 2)
		{
			for (j = 2; j <= i; ++j)
			{
				euclid = Euclid(j, i);
				if (euclid == i)
					counter++;     // ????????????????????§??????
				else if (euclid != 1)               // ?????????????????¨??????Break????¨????????????\
					break;
			}
		}
	}

	cout << counter << endl;

}

int Euclid(int n, int m)
{
	//if (m % n == 0)
	//	return n;
	//else
	//	return Euclid(m%n, n);
	int r = m % n;

	while (r != 0)
	{
		m = n;
		n = r;
		r = m % n;
	}

	return n;
}

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

int main()
{
	int n, i, k, j, h;
	bool flag = false;

	for(i=0; i<30; i++)
	{
		cin >> n;
		h = 0;
		for(k = 2; k <= n; k++)
		{
			flag = false;
			for(j = 2; j < k; j++)
			{
				if(k % j == 0)
				{
					flag = true;
					break;
				}
			}
			if(flag == false)
				h++;
		}
		cout << h << endl;
	}
}

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

int main(){
    int n;
    int count=0;
   
    
    cin>>n;
           for(int a=1;a<=n;a++)
           {
            if(n%a==0)
           
            count=count+1;
                        }
             
    
    cout<<count;
    
    
}

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

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

int main() {
	int n;
	while(scanf("%d",&n) != EOF) {
		vector<int> P;
		for(int i=2;i<=n;++i) {
			if(prime(i)) { P.push_back(i); }
		}
		printf("%d\n",(int)P.size());
	}
	return 0;
}

C++: #include<iostream>
#include<sstream>
#include<cstdio>
#include<fstream>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<string>
using namespace std;
#define N 1000002
bool is_prime(int n){
	if(n<=1)return false;
	if(n==2)return true;
	if(!(n&1))return false;
	for(int x=3;x<=sqrt(n);x+=2) if(!(n%x))return false;
	return true;
}

int main(){
	int n;
	int primes[N];
	primes[0] = primes[1] = 0;
	int cnt = 1;
	primes[2] = cnt;
	for(int x=3;x<=N;++x){
		if(is_prime(x)){
			++cnt;
		}
		primes[x] = cnt;
	}
	while(scanf("%d",&n)==1){
		cout<<primes[n]<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

bool p[1000001];
int pn[1000001];

int main()
{
    for(int i = 0; i < 1000001; i++)
    {
        p[i] = true;
    }
    for(int i = 2; i <= 1000000;i++)
    {
        if(!p[i])
            continue;
        for(int j = 2; i*j <= 1000000; j++)
        {
            p[i*j] = false;

        }
    }
    int result = 0;
    for(int i = 2; i < 1000001; i++)
    {

        if(p[i])
        {
            result++;
        }
        pn[i] = result;
    }
    int n;
    while(cin >> n)
    {
        cout << pn[n]<< endl;
    }
}

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

int main() {
	const int MAX_V = 100000;
	int prime[MAX_V+1];
	int i, k, v;
	for(i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for(i = 2; i*i <= MAX_V; i++) {
		if(prime[i]) {
			for(k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	scanf("%d", &v);
	int count = 0;
	for(i=0;i<=v;i++){
		int isprime = prime[i];
		if(isprime) count ++;
	}
	printf("%d",count);
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#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++;
		}

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

	return 0;
}