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 <string>
#include <cctype>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <map> // pair
#include <set>
#include <string>

#define MAXSIZE 200000
#define PI 3.141592653589
using namespace std;

template<typename T>
T add(T a,T b){
  return a+b;
}

namespace A
{
  int f(void){
    return 1;
  }
}

// int main(){
//   int n;
//   while (std::cin >> n) {
//     int count=0;//素数の数
//     for(int i=2;i<=n;i++){
//       int flag=0;
//       if(i==2){
//         count++;
//         continue;
//       }else if(i%2==0){
//         continue;
//       }
//
//       for(int j=3;j<=sqrt(i);j=j+2){
//         if(i%j==0){
//           flag=1;
//           break;
//         }
//       }
//       if(flag==0){
//         count++;
//       }
//     }
//     std::cout << count << '\n';
//   }
//
// }

int main(){
  int a,t[1000000],u[1000000];
  for(int i=0;i<1000000;i++){
    t[i]=1;
  }
  t[0]=t[1]=u[0]=u[1]=0;
  for(int i=2;i<=1000000;i++){
    if(t[i]==1){
      for(int j=i+i;j<1000000;j+=i)t[j]=0;
      u[i]=u[i-1]+1;
    }else{
      u[i]=u[i-1];
    }
  }
  while(cin>>a){
    cout<<u[a]<<endl;
  }
  return 0;
}

C++: #include<stdio.h>
int num[1000001]={};
int main ()
{
int p,n,m,cou;m=0;cou=0;p=3;


for(int i=2;i<=1000000;i++)
	num[i]=1;
for(int i=2;i<1001;i++){
for(int k=2;k*k<=i;k++){
if(i%k==0){num[i]=0;}}
}
while(scanf("%d",&n)!=EOF)
{
for(int i=2;i<=n;i++)
	cou+=num[i];

if(n==2)cou=1;
if(n==1)cou=0;
//else cou++;
printf("%d\n",cou);
cou=0;
}
return 0;
}

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

long long int a[1000000];

int main(){

  long long int n;

  for(long long int i=2;i*i<1000000;i++){

    if(a[i]==0){
      for(long long int j=i+i;j<1000000;j+=i) a[j]=1;
    }
  }

  while(cin >> n){

    long long int count=0;

    for(long long int i=2;i<=n;i++){
      if(a[i]==0) count++;
    }

    cout << count << endl;

  }
}

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

const int LIMIT = 1000000;

void eratosthenes(int n, bool *primes);

int main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    bool primes[LIMIT];
    primes[0] = primes[1] = false;
    for (int i = 2; i < LIMIT; ++i)
        primes[i] = true;
    eratosthenes(LIMIT, primes);

    int num_of_primes[LIMIT] = {};
    for (int i = 1; i < LIMIT; ++i) {
        num_of_primes[i] = num_of_primes[i-1];
        if (primes[i])
            ++num_of_primes[i];
    }

    int n;
    while (std::cin >> n) {
        std::cout << num_of_primes[n] << std::endl;
    }
}

void eratosthenes(int n, bool *primes)
{
    double root_n = std::sqrt((double) n);
    for (int i = 2; i <= root_n; ++i)
        if (primes[i])
            for (int j = i*i; j <= n; j += i)
                primes[j] = false;
}

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

using namespace std;

#define MAX 1000000

int main(void){

  int n;
  cin >> n;
  int num = 0;

  vector<long int> array(MAX,0);

  array[0] = 2; count++;
  array[1] = 3; count++;

  for(int i = 5 i < n ; i+=2){
    int flag = 0;
    for(int j = 0; array[j]*array[j] <= n;j++){
      if(n % array[i] == 0){
        flag = 1;
        break;
      }
    }
    if(!flag){
      count++;
    }

  }

  cout << count << endl;

  return 0;
}

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

int main(){
  int n ,x=0 ,hoge[1000000]={} ,ans=0;
  while( cin >> n ){
    for( int i=2 ; i<=sqrt(n) ; i++ ){
      for( int j=i*2 ; j<=n ; j+=i ){
	hoge[j] = 1;
      }
    }
    
    for( int i=2 ; i<=n ; i++ ){
      if( hoge[i] == 0 ) ans++;
    }
    cout << ans << endl;
    ans = 0;
  }
}

C++: #include<stdio.h>
int main(void){
int x,i,t=0;
while(scanf("%d",&x)!=EOF){
for(i=2;i*i<x;i++){
if(x%i==0)
break;
t++;
}
printf("%d\n",t);
}
return 0;
}

C++: #include<stdio.h>
int main ()
{
int p,n,m,cou;m=0;cou=0;p=3;
while(scanf("%d",&n)!=EOF)
{
for(int i=3;i<=n;i+=2){
for(int k=3;k*k<i;k++){
if(i%k==0){m++;break;}}
if(m==0)cou++;
m=0;
}
if(n==2)cou=1;
else if(n==1)cou=0;
else cou++;
printf("%d\n",cou);
cou=0;
}
return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define it ::iterator
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double ESP=1e-10;
using namespace std;
int main(){
  int ma=1e7;
  vector<bool>sosu(ma,1);
  sosu[0]=sosu[1]=0;
  for(int i=4;i<ma;i+=2)sosu[i]=0;
  for(int i=3;i<ma;i+=2)
    for(int j=i*3;j<ma;j+=i*2)sosu[j]=0;
  int in;
  while(cin>>in){
    int co=0;
    loop(i,2,in+1)if(sosu[i])co++;
    cout<<co<<endl;
  }
}

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

void setPrimesUnder(int n, bool *p){
    if(n > 2){
        setPrimesUnder(sqrt(n), p);
        for(int i=2; i<=sqrt(n); i++){
            if(!p[i])                       // if i is not a prime
                continue;                   // i++
            for(int j=2; j<=1000000/i; j++) // if i is a prime
                p[i*j] = false;             // the other multiples of i is not a prime
        }
    }
    else{
        p[0] = false;
        p[1] = false;
        p[2] = true;
    }
}

int main(){
    int n;
    bool p[1000000];
    for(int i=0; i<1000000; i++)
        p[i] = true;
    setPrimesUnder(1000000, p);
    
    while(std::cin >> n){
        int count = 0;
        for(int i=0; i<=n; i++){
            if(p[i])
                count++;
        }
        std::cout << count << std::endl;
    }
    return 0;
}

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

bool IsPrime(int m){
    if(m==1){
        return(0);
    }else if(m==2){
        return(1);
    }else if(m%2==0){
        return(0);
    }else{
        for(int i=3;i*i<=m;i+=2){
            if(m%i==0)return(0);
        }
        return(1);
    }
}

int main(){
    int n;
    int r[30];
    bool p[1000000];
    for(int i=1;i<=999999;i++){
        p[i]=IsPrime(i);
    }
    for(int i=0;i<30;i++){
        r[i]=0;
    }
    int j=0;
    while(cin>>n){
        for(int i=1;i<=n;i++){
            r[j]+=p[i];
        }
        cout<<r[j]<<endl;
        j++;
    }
    return(0);
}

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[1000000];
	int count;
	int maxin=0;
	c[0]=c[1]=0;
	for(i=2;i<1000000;i++){
		c[i]=1;
	}

	while(scanf("%d",&n)!=EOF){
		if(n>maxin){
			maxin=n;
		}
		count=n;

		
		for(i=0;i*i<=n;i++){
			if(c[i]==1){
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]==0;
						count--;
					}
				}
			}
		}

		printf("%d",count);


	}





	return 0;
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
bool is_prime[100000];
int prime[100000];

int main(int argc, char const* argv[])
{
	fill(is_prime, is_prime+100000, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int res = 0;
	for(int i = 2; i < 100000; i++){
			if(is_prime[i]){
					res++;
					for(int j = 2; j * i < 100000; j++){
							is_prime[j * i] = false;
					}
			}
			prime[i] = res;
	}
	while(cin >> n){
			cout << prime[n] << endl;
	}
	return 0;
}