Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int main(){
	vector<int> p;
	vector<int> a(1000000);
	bool b;
	int n = 1000000;

	a[0] = a[1] = 0;
	a[2] = 1;
	p.push_back(2);
	for(int i = 3; i < n; i++){
		b = true;
		for(int j = 0; j < p.size(); j++){
			if(p[j]*p[j] > i){
				break;
			}
			if(i % p[j] == 0){
				b = false;
				break;
			}
		}
		if(b){
			p.push_back(i);
		}
		a[i] = p.size();
	}

	while(cin >> n){

		cout << a[n] << endl;
	}

	return 0;
}

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

using namespace std;

const int N_MAX = 1000000;

int table[N_MAX];

int main() {
  table[0] = table[1] = 1;
  int sq = sqrt(N_MAX);
  for (int i = 2; i < sq+1; i++) {
    if (table[i] == 0) {
      for (int j = i*2; j < N_MAX; j += i) {
        table[j] = 1;
      }
    }
  }
  int n;
  while (cin >> n) {

    int ans = 0;
    for (int i = 0; i < n; i++) {
      if (table[i] == 0) ans++;
    }
    cout << ans << endl;

  }

  return 0;
}

C++: #include<stdio.h>



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

	while((scanf("%d",&n)!=EOF)&&(n!=0)){
		
		count=0;
		for(i=0;i*i<=n;i++){
			data[i]=count;
			if(c[i]==1){
				count++;
				for(j=i+1;j<=n;j++){
					if(j%i==0){

					}
				}
			}
		}

		printf("%d",data[n]);
	}
	return 0;
}

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

bool prime(int n);

int main(void) {
	using namespace std;
	int x;
	int count;
	while (cin >> x) {
		count = 0;
		for (int i = x; i > 1; i--) {
			if (prime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

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