Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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

/*
10
3
11

4
2
5
*/

const int MAX_N = 1e6 + 10;
int N = 0;

bool is_prime[MAX_N + 1];
void sieve(int n) {
    fill(is_prime, is_prime + n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i * i <= n; i++) {
        if (is_prime[i]) {
            for (int j = 2 * i; j <= n; j += i) {
                is_prime[j] = false;
            }
        }
    }
}

void solve() {
    int res = 0;
    for (int i = 2; i <= N; i++) {
        if (is_prime[i]) {
            res++;
        }
    }

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

int main() {
    sieve(MAX_N);
    while (scanf("%d", &N) != EOF) {
        solve();
    }

    return 0;
}

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

using namespace std;

int main(int argc, char *argv[]) {
  int n;
  vector<int> result;
  while (cin >> n) {
    vector<int> nums;
    nums.reserve(n+1);
    for (int i = 0; i <= n; i++)
      nums.push_back(i);

    for (int i = 2; i <= n; i++) {
      if (nums[i] == 0)
        continue;
      int hoge = nums[i];
      for (int j = i+1; j <= n; j++) {
        if (nums[j] == 0)
          continue;
        else if (nums[j] % hoge == 0)
          nums[j] = 0;
      }
    }

    int piyo = 0;
    for (int i = 2; i <= n; i++)
      if (nums[i])
        piyo++;
    result.push_back(piyo);
  }

  for (int i = 0; i < result.size(); i++)
    cout << result[i] << endl;
  return 0;
}

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

bool isPrime(int x){
	if(x == 0 || x == 1) return false;
	for(int i=2;i*i<=x;i++){
		if(x % i == 0) return false;
	}
	return true;
}

int main(void){
	int n;
	int ans = 0;
	
	while(cin>>n){
		for(int i=2;i<=n;i++){
			if(isPrime(i)) ans++;
		}
		printf("%d\n",ans);
	}

	return 0;
}

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

int main(){
    bool prime[1000000];
    prime[0] = prime[1] = false;
    
    int n, cnt;
    
    while(cin >> n){
        for(int i = 2;i <= n;i++){
            prime[i] = true;
        }
        cnt = 0;
        
        for(int i = 2;i <= sqrt(n);i++){
            if(prime[i]){
                for(int j = 2*i;j<= n;j++){
                    if(j%i == 0){
                        prime[j] = false;
                    }
                }
            }
        }
        
        for(int i = 2;i <= n;i++){
            if(prime[i]){
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }
    
    return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
int p(long x)
{
    long i,j=sqrt(x),k=1;
    for(i=2;i<=(j);i++)
    {
        if(x%i==0){
            k=0;
            //return k;
        break;

        }
    }
    if(k==1)return 1;
    else return 2;
}
using namespace std;
int main()
{
    double a,b,c,i,n,s=0;
   // i=1;

    //while(i){
       // if(i>=30)break;
        cin>>n;
        s=0;
    //a=sqrt(n);
    for(i=2;i<=n;i++)
    {
        if(p(i)==1){s++;}
    }

    cout<<s<<endl;
  //  i++;
    //}


    return 0;
}

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

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

C++: #include <iostream>

using namespace std;

bool eratosthenes[1000000];

int main()
{
	for (int i=0; i<1000000; i++) eratosthenes[i] = true;		
	eratosthenes[0] = eratosthenes[1] = false;
	
		for (int i=2; i<1000000; i++) {
		if (!eratosthenes[i]) continue;
		for (int j=2; i*j<1000000; j++) eratosthenes[i*j] = false;
	}
	
	int n;
	while (cin >> n) {
	
		int count = 0;
		for (int i=0; i<=n; i++) {
			if(eratosthenes[i]) count++;
		}
		
		cout << count << endl;
	}
	
	return 0;
}

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

#define N 1000000L
bool num[N];

void furui(void){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0L] = false;
  num[1L] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == true) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int sum=0;
		for(int i=2;i<=n;i++){
			for(int j=2;j<i;j++){
				if(i%j==0){
					goto loop;
				}
			}
			sum++;
			loop:;
		}
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstring>
#include<cstdio>
using namespace std;
#define N 10000000
int a[N];
int p[N];
int cnt;
void Init(){
    memset(a,0,sizeof(a));
    cnt=0;
    for(int i=2;i<N;i++){
        if(a[i]==0){
            p[cnt++]=i;
        }
        for(int j=0;j<cnt&&i*p[j]<N;j++){
            a[i*p[j]]=1;
            if(i%p[j]==0)break;//?个合数?被它的最小素因子?去正好一次
        }
    }
}
int main(){
    Init();
    int n;
    while(~scanf("%d",&n)){
        int k=lower_bound(p,p+n,n)-p+1;
        if(a[n]==0)printf("%d\n",k);
        else printf("%d\n",k-1);
    }
    return 0;
}

C++: #include <iostream>

using namespace std;
bool IsPrime[1000000];
int PrimeNum[1000000];

void PrimeCalc()
{
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	int count = 0;
	PrimeNum[0] = PrimeNum[1] = 0;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			++count;
			PrimeNum[i] = count;
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
		else
		{
			PrimeNum[i] = PrimeNum[i - 1];
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n)
	{
		cout << PrimeNum[n] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include<stdio.h>

int main(void)
{
	int data,i,j,k=0,l=0,kai=0,s[100000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai[k]=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				 j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai+=1;
				}
			}
		}
		printf("%d",kai);
		kai=0;
	}

  return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<windows.h>
#include<conio.h>
#include<String>
#include<time.h>
#include<math.h>

using namespace std;
int c = 0;
int i = 1;
unsigned long long a = 0;
unsigned long long b = 0;
unsigned long long sosuu[100000] = { 0 };
char fire = 0;
int pattara = 0;

int sub(int c) {

	
	
	/*while(i>-1)*/
	for (int i = 2; i<=c; i++){
		/*for (int z = 0; z < a;z++){*/
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		if (b == 1) {
			/*fire = _getch();*/
			pattara++;
			
		}
		b = 0;
		/*i++;*/
	}

	
	return 0;
}


int main(){
	while (scanf("%d", &c) != EOF){

		sub(c);
		cout << pattara << endl;
		pattara = 0;
	}


}