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 <iostream>
#include <cmath>
#include <vector>
using namespace std;

int main(){
    vector<int> prime;
    int n;
    for(int i=2;i<1000000;i++){
        bool isprime=true;
        for(int j=2;j<=sqrt(i);j++){
            if(i%j==0){
                isprime=false;
                break;
            }
        }
        if(isprime) prime.push_back(i);
    }
    while(cin >> n){
        for(int i=0;i<prime.size();i++){
            if(prime[i]>n){
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}

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

int main(){
	int n;
	bool num[MAX_N];
	for(int i=0;i<MAX_N;i++) num[i]=false; 

	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(num[i]) continue;
			for(int j=2;j<=n/i;j++) num[i*j]=true;
			ans++;
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

using namespace std;

int prime[10000];
bool is_prime[1000000];

int sosuu(int n){
    int p=0;
    for (int i=0; i<=n; i++)
        is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for (int i=2; i<=n; i++) {
        if(is_prime[i]){
            prime[p++]=i;
            for (int j=i*2; j<=n; j+=i) {
                is_prime[j]=false;
            }
        }
    }
    return p;
}

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

C++: #include<iostream>
using namespace std;
int PrimeNum(int n){
  for(int i = 2;i <= n;i++){
    if(i == n){
      return 1;
    }
    if(n % i == 0){
      return 0;
    }
  }
}
int main(){
  int n,num;
  for(cin >> n;n != 0;cin >> n){
    num = 0;
     for(int k = 2;k <= n;k++){
       if(PrimeNum(k) == 1){
	 num = num +1;
       } 
     }
     cout << num;
  }
}

C++: #include <iostream>
#include <cmath>
using namespace std;
bool whether(int num);
int count(int num);

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

bool whether(int num){//if num is prime, 1
    int s=sqrt(num);
    for(int i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    return 1;
}

int count(int num){
    int a=1;
    if(num<=2){ return num-1; }
    for(int i=3; i<=num; i+=2){
        if(whether(i)){ a+=1; }
    }
    return a;
}

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

int main(void){
  int n;
  while(cin >> n){
    if(n < 3){
      if(n < 2){
	cout << 0 << endl;
      }else{
	cout << 1 << endl;
      }
    }
    int ans = 0;
    for(int i = 3; i <= n; i += 2){
      bool flag = true;
      for(int j = 3; j <= sqrt(i); j += 2){
	if(i % j == 0){
	  flag = false;
	}
      }
      if(flag)
	ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count[1000000];
		count[1] = 1;
	for(int x=2;x<=1000000;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count[i] = count[i-1]+1;
	}
	while(cin >> N){
		cout << count[N] << endl;
	}
	return 0;
}

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

int main(void) {
    int n;
    while(cin >> n) {
        int a[n];
        for(int i = 0; i <= n; i++) {
            a[i] = 1;
        }
        for(int i = 2; i <= sqrt(n); i++) {
            if(a[i]) {
                for(int j = 2; i * j <= n; j++) {
                    a[i * j] = 0;
                }
            }
        }
        int cnt = 0;
        for(int i = 2; i <= n; i++)
            if (a[i]) cnt++;
        cout << cnt << endl;
    }
}

C++: #include<iostream>
#include<stdlib.h>
main(){
	int i,j,n;//,p[1000000];
	std::cin>>n;

	int *p=(int *)malloc(8000000);
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<=n;i++)
		j+=p[i];
	std::cout<<j<<std::endl;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;
	bool prime[1000000] = {false};
	prime[1] = true; //1???????????\	
	
	while(cin >> n){	
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] =true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

C++: #include <iostream>

using namespace std;

typedef long long ll;

int main()
{
    int n;
    while(cin >> n) {
        int ans = 1;
        
        for(int i = 3; i <= n; i+=2) {
            bool isPrime = true;
            for(int j = 3; (j * j) <= i; j+=2) {
                if(i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if(isPrime) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: 
#include <iostream>
#include <stdlib.h>
using namespace std;
#define thefor(i,end) for (i=0;i<end;i++)
int main()
{    
	int n,con,a,i,j;
	while(cin>>n)
	{
		con=1;
		for (i=3;i<=n;i++)
		{
			for (j=2;j<i;j++)
			{
				if (i%j==0)
				{
					break;
				}
			}
			if (j==i)
			{
				con++;
			}
		}
		cout<<con<<endl;
	}
	
}

C++: #include <bits/stdc++.h>

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

inline int Sieve_of_Eratothenes(const int n) {

	std::vector<bool> flg(n + 1, true);
	for (int i = 2; i*i <= n; i++) {
		if (flg[i]) {
			for (int j = i + i; j <= n; j += i) {
				flg[j] = false;
			}
		}
	}

	return(std::count(flg.begin(), flg.end(), true) - 2);

}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::vector<int> A;
	while (std::cin >> a) {
		A.push_back(a);
	}

	std::for_each(A.begin(), A.end(),
		[](int i) {std::cout << Sieve_of_Eratothenes(i) << std::endl; });
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isprime(int n) {
	if (n == 2)return true;
	for (int i = 3; i <= sqrt(n); i += 2) if (n%i == 0)return false;
	return true;
}
int main() {
	long long n; while(cin >> n){
		long long sum;
		if (n == 1)sum = 0;
		else {
			sum = 1;
			for (int i = 3; i < n + 1; i += 2) {
				if (isprime(i))sum++;
			}
		}
		cout << sum << '\n';
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

const int N = 1e6L + 11;
int p[N];
int sum[N];

int main() {
	iota(p, p + N, 0);
	for(int i = 2; i < N; i ++) if(p[i] == i)
		for(int j = i; j < N; j += i) p[j] = i;
	for(int i = 2; i < N; i ++)
		sum[i] = sum[i - 1] + (p[i] == i);
	ios :: sync_with_stdio(false);
	int n;
	while(cin >> n)
		cout << sum[n] << '\n';
	return 0;
}

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