Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

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

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

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i=3;
	while( i <= sqrt(x) ){
		if(x%i==0)return 0;
		i = i + 2;
	}
	return 1;
}
int main(){
	int n,c;
	while(scanf("%d",&n)!=EOF){
		c=1;
		for(int i=3;i<=n;i+=2){
			if(isprime(i))c++;

		}
		printf("%d\n",c);
	}
	return 0;
}

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

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

int main(void) { 
	int p,n; 
	while(cin >> n){ 
        int COUNT = 0;
		for (int i = 2; i <= n; i++){ 
			if (IsPrime(i)) 
				COUNT++; 
		} 
		cout << COUNT << endl;
	}
	return 0; 
}

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

using namespace std;

bool isPrime(int n) {
    if (n < 2) {
        return false;
    }
    else if (n == 2) {
        return true;
    }
    else if(n%2 == 0) {
        return false;
    }
    
    double num = sqrt(n);
    for (int i = 3; i <= num; i += 2) {
        if (n%i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
    int n;
    int cnt = 0;
    cin >> n;
    for (int i = 2; i <= n; i++) {
        cnt += isPrime(i);
    }
    cout << cnt << endl;
    return 0;
}

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

#define MAX_N 2000000
int prime[MAX_N];



int main(){
	prime[1] = 1;
	prime[2] = 0;
	prime[3] = 0;
	for(int i = 2; i<=MAX_N;i++){
		if(prime[i] == 0)
			for(int j=2*i;j<=MAX_N;j=j+i)
				prime[j] = 1;
	}
	
	int n;
	int num=0;
	while(true){
		if (cin.eof())
			break;
		cin >> n;

		for(int k = 1;k<=n; k++){
			if(prime[k]==0)
				num++;
		}
		cout << num << endl;
		num = 0;
	}
	return 0;
}

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

int main(){
  int n,i,j;
  while(cin >> n) {
    
    int k = 0, a[n];
    a[0] = 2;
  
    for (i = 3; i <= n; i = i + 2) {
      for (j = 0; j <= k; j++) {
        if(i % a[j] == 0 ) break;
        if(i <= a[j] * a[j]) {
          k++;
          a[k] =i;
          break;
        }
        
      }
      if(j == k + 1) {
        k++;
        a[k] = i;
      }
    }
    cout << k+1 << endl;
  }
  
  return 0;
}

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

int main(){
  int a;
  int i, j;
  int past=1, a_sqrt;
  int count;
  bool chk[1000000];

  for(i=1; i<1000000; i++) chk[i]=true;

  return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n, p, k, count;
	vector<int> num(1000000, 1);
	while(cin>>n){
		count=0;
		num[0]=0; num[1]=0;
		for(int i=4; i<=n; i+=2){
		num[i]=0;
		}
		for(int i=0; i<=n; i++){
			p = i+i+3;
			for(k=p+p; k<=n; k+=p){
				num[k]=0;
			}
		}
		for(int i=0; i<=n; i++){
			if(num[i]==1)
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

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

int main(){
	int n;
	int *prime,i,j;
	prime = new int[80000];
	int *answer = new int[MAX];
	int count;
	bool flag;

	count = 1;
	answer[1] = 0;
	answer[2] = 1;
	for(i = 3; i <= 1000000; i+=2){
		flag = true;
		for(j = 0; j < count; j++){
			if(i % prime[j] == 0){
				flag = false;
				break;
			}
			if(prime[j] * prime[j] > i) break;
		}
		if(flag == true){
			prime[count++] = i;
		}
		answer[i] = count;
		answer[i+1] = count;
	}
	while((cin >> n)!= NULL){
		cout << answer[n] << endl;
	}
	return 0;
}

C++: #include<stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1];
int pcount[MAX_V];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

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

int prime(int num){

	if(num<2){
		return 0;
	}else if(num==2){
		return 1;
	}else if(num%2==0){
		return 0;
	}
	
	for(int s=3; pow(s,2)<=num; s+=2){
		if(num%s==0){
			return 0;
		}
	}
	
	return 1;
}

int main(){
	int num;
	
	while(cin >> num){
		int count=0;
		for(int i=0; i<=num; i++){
			if(prime(i)==1){
				count++;
			}
		}
		
		cout << count << endl;
	}
	
	return 0;
}

C++: #include<cstdio>
int sosu[1000000]={};
bool f[1000000]={false};
int main(){
  sosu[2] = 1;
  for(int i=3;i<=999999;i+=2){
    if(!f[i]){
      sosu[i] = 1;
      if(i < 1000){
	for(int j=i*i;j<=999999;j+=i) f[j] = true;
      }
    }
    sosu[i] += sosu[i-1];
    sosu[i+1] += sosu[i];
  }
  int n;
  while(scanf("%d",&n)!=EOF) printf("%d\n",sosu[n]);
  return(0);
}

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

using namespace std;

int setPrimeNumberCount(int n) {
    int count = 0;
    vector<int> primeList;
    vector<int> searchList;
    
    if(n >= 2){
        for(int i = 2; i <= n; i++) {
            searchList.push_back(i);
        }
        
        vector<int>::iterator end_it;
        
        for(int i = 0; i <= n; i++) {
            primeList.push_back(searchList[0]);
            
            for(vector< int >::iterator it = searchList.begin(); it != searchList.end();) {
                if(*it % primeList[count] == 0) {
                    it = searchList.erase(it);
                }
                else {
                    ++it;
                }
            }
            count++;
            if(pow(primeList[i],2) > searchList.back()) {
                for(int i = 0; i < searchList.size(); i++) {
                    primeList.push_back(searchList[i]);
                    count++;
                }
                break;
            }
        }
    }
    return count;
}

int main(void) {
    int n;
    int count = 0;
    
    while(cin >> n) {
        count = setPrimeNumberCount(n);
        cout << count << endl;
        count = 0;
    }
    return 0;
}

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

bool IsPrime(int p)
{
	for (int i = 2; i <= sqrt(p); i++)
	{
		if (p % i == 0) return false;
	}
	return true;
}

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