Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

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

using namespace std;

int A[1000000];
int Pream(int n)
{
	int kusa = (int)sqrt((double)n);
	int mama = 0;

	for (int i = 0; i < n; i++)
		A[i] = 1;  // ??¨????????°???1????????????
	A[0] = 0;    // 1????´???°??§?????????

	for (int i = 1; i < kusa; i++) {
		if (A[i] == 1)   // prime[i]????´???°??????
		{
			for (int j = (i + 1); (i + 1) * j <= n; j++)
				A[(i + 1) * j - 1] = 0;  // ?´???°????????°????´???°??§?????????
		}
	}
	for (int i = 0; i < n; i++)
		if (A[i] == 1)  // 1????????£???????????????????´???°
			mama++;

	return mama;
}

int main()
{
	int n;
	cin >> n;
	while (n != -1)
	{
		cout << Pream(n) << endl;
		cin >> n;
	}
	return 0;
}

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

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		for(int j = 2;i*j < 1000000;j++){
			c[i*j] = true;
		}
		t[i]=t[i-1]+!c[i];
	}
	for(int n;cin>>n;n++){
		cout << t[n] << endl;
	}
	return 0;
}

C++: #include <stdio.h>
#include <math.h>
#include <time.h>

int whether(int num);
int count(int num);

int main(){
	int n;
	int a;
	clock_t c, d;

	while(1){
		if(scanf("%d",&n) != -1) break;
		a = count(n);
		printf("%d\n",a); 
}

	return 0;
}

int whether(int num){
	int s=sqrt(num);
	int i;
	for(i=3; i<=s; i+=2){ if(num%i==0) return 0; }

	return 1;
}

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

	return a;
}

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

const int max_n = 1000000;
int prime[max_n];
bool is_prime[max_n+1];

int sieve(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=2*i;j<=n;j+=i)
				is_prime[j] = false;
		}
	}
	return p;
}

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

C++: #include <cstdio>

const int NUM = 1000000;
bool prime[NUM];
int primeNum[NUM];

int main(){

  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

	for(int i=0,c=0;i<NUM;i++){
		prime[i]&&c++;
		primeNum[i] = c;
	}
	for(int n;scanf("%d",&n)+1;printf("%d\n",primeNum[n]));
}

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

using namespace std;

int main(void) {
	int n;
	
	vector<int> prmcnt_v;

	while(cin >> n) {
		int pcnt = 0;
		for (int i = 2; i <= n; i++) {
			for (int j = 2; j <= i; j++) {
				if (j % 2 == 0 && j != 2) {
					continue;
				}

				if (i % j == 0){
					if (i == j) {
						pcnt++;
					}
					else {
						break;
					}
				}
			}
		}
		prmcnt_v.push_back(pcnt);
	}


	for (int k = 0; k < prmcnt_v.size(); k++) {
		cout << prmcnt_v[k] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1e6+7;
int prime[maxn];
bool is_prime[maxn];
int n,p=-1;

void Eular()
{
    for(int i=1;i<=maxn-7;i++)
        is_prime[i]=true;
    for(int i=2;i<=maxn-7;i++)
    {
        if(is_prime[i])
            prime[++p]=i;
        for(int j=0;j<=p && i*prime[j] <= maxn-7;j++)
            is_prime[i*prime[j]]=false;
    }
}

int main()
{
    Eular();
    while(~scanf("%d",&n))
    {
        int i=0,ans=0;
        while(i<=p && prime[i]<=n) i++,ans++;
        printf("%d\n",ans);
    }
    return 0;
}

C++: /// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
/// http://www.tsg.ne.jp/TT/tsg/c/mansaku/P01.html
#include<iostream>
#include<cmath>
using namespace std;

int main(){
    int n, cnt=0;
    for(;cin>>n;){
        for(int i = 3; i<=n; i+=2){
            int k= 0;
            for(int j=3; j<sqrt(i); j+=2){
                if(i%j==0){
                    k=1;
                    break;
                }
            }
            if(k==0) cnt++;
        }
        printf("%d\n", cnt);

    }

    return 0;
}

C++: #include <stdio.h>

int main(void) {
	int i,ii,t,mn;
	while(scanf("%d", &mn) != EOF){
		t = 0;
		for(i = 2;i <= mn;i++){
			t++;
			for(ii = 2;ii < i;ii++){
				if (i % ii == 0){
					t--;
					break;
				}
			}
		}
		printf("%d\n",t);
	}
	return 0;
}

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

using namespace std;

bool judge(int);

int main(){
	const int MAX_VALUE = (int)1e7;
	vector<bool> primeNums(MAX_VALUE);
	
	for(int i = 1; i < MAX_VALUE; i ++)
		primeNums[i]=judge(i);

	for(int n, count = 0; cin >> n; cout << count << endl, count = 0)
		for(int i=1; i<=n; i++) if(primeNums[i]) count++;

	return 0;
}

bool judge(int n){
	if(n==2||n==3) return true;
	if(n==1||n%2==0) return false;
	for(int i = 3; i*i <= n; i += 2)
		if(n%i==0) return false;

	return true;
}

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

#define N 1000000

using namespace std;

int pn[N];

void Eratosthenes()
{
	for (int i=0; i<N; i++) {
		pn[i] = 1;
	}

	for (int i=2; i < (int)sqrt((double)N); i++) {
		if(pn[i]) {
			for (int j=0; i*(j+2)<N; j++) {
				pn[i*(j+2)] = 0;
			}
		}
	}
}

int main()
{
	int n;

	Eratosthenes();

	while (cin >> n)
	{
		int cont = 0;
		for (int i=2; i<=n; i++) {
			if(pn[i])	cont++;
		}

		cout << cont << endl;
	}

	return 0;
}

C++: #include <stdio.h>
#include <string.h>
int main(void){
    int n,a,b,c;
    char x[1000000];
    while(~scanf("%d",&n)){
        memset(x,0,sizeof(x));
        for(a=2,c=0;a<=n;a++){
            if(x[a])continue;
            c++;
            for(b=a*2;b<=n;b+=a)x[b]=1;
        }
        printf("%d\n",c);
    }
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
#define MAX_N 999999
bool prime_check(int n, int k = 2){
	if (n < k * k) return true;
	if (n % k == 0) return false;
	return prime_check(n, k + 1);
}
int main(){
  int n;
  bool isprime[MAX_N+1];
  for(int i=2; i<=MAX_N; i++) isprime[i] = prime_check(i);
  while(cin >> n){
    int cnt=0;
    for(int i=2; i<=n; i++){
        if(isprime[i] == true) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

C++: #include <iostream>
#define N 100000
#define rep(i,n) for(int i=0;i<n;i++)

int main(void)
{
    bool a[N+1];
    int prime[N], n;
    rep(i,N)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(cin >> n)
        cout << prime[n] << endl;
    
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
int pcount[MAX_V+1];
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; 
    
}