Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

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

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

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] << '\n' << C[1] << '\n' << C[2] << '\n';

	return 0;
}

C++: #include <bitset> // compact STL for Sieve, better than vector<bool>!
#include <vector>
#include <cstdio>
#include <iostream>
#define ll long long 
#define vi vector<int>

using namespace std;

ll _sieve_size; 
bitset<10000010> bs; 
vi primes; 
void sieve(ll upperbound) { 
_sieve_size = upperbound + 1; 
bs.set(); 
bs[0] = bs[1] = 0; 
for (ll i = 2; i <= _sieve_size; i++) if (bs[i]) {
for (ll j = i * i; j <= _sieve_size; j += i) bs[j] = 0;
primes.push_back((int)i);
} } 
bool isPrime(ll N) { 
if (N <= _sieve_size) return bs[N]; 
for (int i = 0; i < (int)primes.size(); i++)
if (N % primes[i] == 0) return false;
return true; 
} 

int tc,a;
int TestCase,x;

int main()
{
	sieve(1000100); 
	while(scanf("%d",&tc)!=EOF)
    {
        x=0;
        while(tc >= primes[x])
        {
            x++;
        }
        printf("%d\n",x);
    }
    return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}

int main()
{
	
//	cut here before submit 
//	freopen("testcase.prime", "r", stdin);
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	vector <int> prime(n+1, 0);

	int i;
	int count = 0;
	for (i = 2; i <= n; ++i){
		if (isprime(i)){
			++count;
		} // end if
		prime[i] = count;
	} // end for

	cout << prime[n] << endl; 

	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;

	while ( scanf("%d" , &num) != EOF ){	
		p[0] = false;
		p[1] = false;
		for (int i=2 ; i<=MAX ; i++){
			p[i] = true;
		}
		answer = 0;

		for (int i=2 ; i<=sqrt(MAX)+1 ; i++){
			if (p[i]==1){
				for (int j=i*2; j<=MAX; j=j+i){
					p[j] = false;
				}
			}
		}

		for (int i=0; i<=num; i++){
			if (p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
	return 0;
}

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

int prime[1000010];
bool is_prime[1000010];
int n;
int main()
{
	while(cin>>n)
	{
		int p = 0;
		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])
			{
				prime[p++] = i;
				for(int j = 2 * i;j <= n;j = j + i)
				{
					is_prime[j] = false;
				}
			}
		}
		cout<<p<<endl;
	}
}

C++: #include <iostream>
using namespace std;
??
#define Max 1000000
??
int prime [10000000];
??
int main()
{
????????int n, out;
??
????????for (int i = 2; i * i < Max; i++){
????????????????if (prime[i] == 0){
????????????????????????for (int j = i; j < Max; j += i){
????????????????????????????????if (!(j == i)) prime[j] = 1;
????????????????????????}
????????????????}
????????}
??
????????while (cin >> n){
????????????????out = 0;
????????????????for (int i = 0; i <= n; i++){
????????????????????????if (prime[i] == 0) out++;
????????????????}
????????????????cout << out - 2 << endl;
????????}
????????return(0);
}

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

bool IsPrime(int n){

    if(n % 2 == 0)
        return false;
 
    for(int i = 3; i * i <= n; i += 2)
         if(n % i == 0)
            return false;
    return true;
}
int CheckNum(int input){
	int count = 1;

	for(int i = 2; i < input; ++i){

		if(IsPrime(i)) ++count;
	}
	return count;
}
int main() {
	int input;

	cout << CheckNum(input) << endl;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int x)
{
	if (x < 2)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	for (int i = 3; i <= (int)sqrt(x); i+=2)
		if (x%i == 0)
			return false;
	return true;
}
int main()
{
	while (true)
	{
		int n;
		cin >> n;
		if (cin.fail())
			break;
		int count = 0;
		for (int i = 1; i <= n; i++)
			if (isPrime(i))
				count++;
		cout << count << endl;
	}
}

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

using namespace std;

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

int main(void) {
	int n, total = 0;
	cin >> n;
	for (int i = 2; i <= n; i++) {
		if (isprime(i))
			total++;
	}
	cout << total << endl;
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
typedef long long int ll;

long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }

vector<int> makePrimes(int n) { 
    vector<int> res, pr(n + 1, 1);
    pr[0] = pr[1] = 0;
    for(int p=2;p<sqrt(n)+2;p++) if (pr[p]) for (int x = p * 2; x <= n; x += p) pr[x] = 0;
    for(int p=2;p<n + 1;p++) if (pr[p]) res.push_back(p);
    return res;
}

int main(){
	int a;
	while(scanf("%d",&a)!=EOF){
		cout << makePrimes(a).size() << endl;
	}
}

C++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int count = 0;
	/*int m = 2, n = 0, num;

	cin >> num;

	int *data = new int[num + 1];
	int *result = new int[num + 1];

	data[0] = 0;
	data[1] = 0;

	do
	{
		for (i = 2 * m; i < num + 1; i += m)
		{

		}
	}
	while
	{

	}*/
	const int N = 9999999;
	int n;
	std::vector<bool> isPrime(N + 1, true);    // ?´???°????????°?????¨??¨ON???

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

				for (int k = i + i; k <= n; k += i)
					isPrime[k] = false;      // ?´???°????????°????´???°????????°?????¨???OFF???
			}
		}

		cout << count << endl;
	}
	
	return 0;






	
}

C++: #include<stdio.h>

int isPrime(int n){
  int i;
  if(n<2)return 0;
  if(n==2)return 1;
  if(n%2==0)return 0;
  for(i=3;i<=n/i;i+=2)
    if(n%i==0)
      return 0;
  return 1;
}

int main(){
  int a;
  while(scanf("%d",&a)!=EOF){
    int i,ans=0;
    for(i=0;i<=a;i++){
      if(isPrime(i))ans++;
    }
    printf("%d\n",ans);
  }
  return 0;
}