Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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;
	}


}