Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = i
        }

        Soe()

        for i := 0; i < MAX; i++ {
                primes[i] %= 2
        }
        primes[1] = 0
        primes[2] = 1
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := 2; j < MAX/i; j++ {
                                if i * j < MAX {
                                        primes[i*j] = 0
                                }
                        }
                }
        }
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

#define MAX 1000000

static bool gosei[MAX];

void b(){
	for(int i=2;gosei[i]==false&&i<MAX;i++)
		for(int j=2,k;(k=i*j)<MAX;j++)
			gosei[k]=true;
}

int c(int n){
	int cnt=0;
	for(int i=2;i<=n;i++)
		if(!(gosei[i]))cnt++;
	return cnt;
}

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

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

int main()
{
 bool prime[1000000];

 prime[0]=prime[1]=false;
 for(int i=2;i<1000000;i++){
	prime[i]=true;
 }

 for(int i=2;i*i<1000000;i++){
	if(prime[i]){
		for(int j=i*i;j<1000000;j+=i){
			prime[j]=false;
		}
	}
 }

 int n_prime[1000000];
 int cnt=0;
 for(int i=0;i<1000000;i++){
	if(prime[i]){
		cnt++;
	}
 	n_prime[i]=cnt;
 }

 while(true){
	int n;
	cin>>n;
	if(cin.eof()){
		break;
	}
	if(n==0){
		break;
	}
	cout<<"??¬?´???°?????°???"<<n_prime[n]<<endl;
 }
 return 0;
}

C++: #include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
using namespace std;

//int is_prime(int N){
//
//	int root = sqrt(N);
//	int i;
//	for(i = 3; i<= root; i+=2){
//		if(N%i==0)
//			return 0;
//	}
//	if(i>root)
//		return 1;
//}


bool isPrime(int num) {
    if (num <= 3) {
        return num > 1;
    } else if (num % 2 == 0 || num % 3 == 0) {
        return false;
    } else {
		int root = sqrt(num);
        for (int i = 5; i <= root; i += 6) {
            if (num % i == 0 || num % (i + 2) == 0) {
                return false;
            }
        }
        return true;
    }
}

int main(){

	int A;
	int count = 1;



	while( scanf("%d", &A) != EOF ){
		count = 1;

		if(A<2) count=0;
		else if (A==2) count=1;
		else{
			for(int i=3; i<=A; i+=2){
				if(isPrime(i) == true)
					count++;
			}
		}

		printf("%d\n", count);
	}


	return 0;
}

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

int f[1000001];
int main(){
    fill_n(f,1000001,1);
    f[0]=f[1]=0;
    
    for(int i=2;i<1000001;i++){
        f[i]+=f[i-1];
        if(!f[i])continue;
        for(int j=i+i;j<1000001;j+=i)f[j]=0;
    }
    
    int N;
    
    while(scanf("%d",&N),&N){
        printf("%d\n",f[N]);
    }
    
    return 0;
    
}

C++: #include<stdio.h>

int	main(){
	int	i,	k,	x,	cnt,	data[1000000];
	for(i	=	2;	i	<=	1000000;	i++){
		data[i]	=	1;
	}
	for(i	=	2;	i	*	i	<=	1000000;	i++){
		if(data[i]){
			for(k	=	2	*	i;	k	<=	1000000;	k	+=	i){
				data[k]	=	0;
			}
		}
	}
	while(1){
		cnt	=	0;
		scanf("%d",	&x);
		if(x	==	0)break;
		for(i	=	2;	i	<=	x;	i++){
			if(data[x]	==	1)cnt++;
		}
		printf("%d\n",	cnt);
	}
	return	0;
}

C++: #include <iostream>
#include <stdio.h>
#include <algorithm>
#include <functional>

using namespace std;

#define MAXN 1000016

int isprime[MAXN];

void sieve(int n)
{
	int i, j, num, p = 0;
	fill(isprime, isprime + MAXN + 1, 1);
	for (i = 2, num = 1; i <= n; i++)
	{
		if (isprime[i])
		{
			isprime[i] = num++;
			for (j = 2 * i; j <= n; j += i)
				isprime[j] = 0;
		}
	}
}

int main()
{
	int n;
	sieve(MAXN);
	while (scanf("%d", &n) != EOF)
	{
		while (!isprime[n])
		{
			n--;
		}
		printf("%d\n", isprime[n]);
	}
	return 0;
}

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

int main(){
	int n;
	while(cin >> n){
		int counter = 0;
		if(n != 1)counter++;
		for(int i = 3; i <= n; i += 2){
			for(int j = 2; j <= sqrt(i); j++){
				if(i % j == 0)goto divisible;
			}
			counter ++;
			divisible:;
		}
		cout << counter << endl;
	}
}

C++: #include <cstdio>
#include <algorithm>

#define rep(i, n) for(int i = 0; i < (n); ++i)

using namespace std;

bool prime[(int)1e7];
int integral[(int)1e7];

int main(){
	fill(prime + 2, prime + (int)1e7, true);
	
	for(int i = 2; i < (int)1e7; ++i){
		if(prime[i]){
			for(int j = i * 2; j < (int)1e7; j += i){
				prime[j] = false;
			}
		}
	}

	for(int i = 1; i < (int)1e7; ++i){
		integral[i] = integral[i - 1] + prime[i];
	}

	int n;
	while(scanf("%d", &n) != EOF){
		printf("%d\n", integral[n]);
	}
	return 0;
}

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

using namespace std;

#define MAX_NUM	1000000

int solist[MAX_NUM] = { 0 };

int main(int argc, char* argv[])
{
	int i; 
	int num;
	int count;
	int val;

	solist[0] = 1;
	solist[1] = 1;

	for (num = 2; num < MAX_NUM; num++) {
		if (solist[num]) continue;
		for (i = num * 2; i < MAX_NUM; i += num) {
			solist[i] = 1;
		}
	}

	while (cin >> val) {
		count = 0;
		for (i = 1; i <= val; i++) {
			if (solist[i] == 0) {
				count++;
			}
		}
		cout << count << endl;
	}
	
	return 0;
}

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

 void prima()
    {
        bool isprima;
        int a, n;
        while(cin >> a)
        {
            n = 0;
            for(int i = 2; i <= a; i++)
            {
                isprima = true;
                for(int j = 2; j < i; j++)
                {
                    if( i == 2)
                    {
                        isprima = true;
                        break;
                    }
                    else if(i % j == 0)
                    {
                        isprima = false;
                        break;
                    }
                }
                if(isprima) n++;
            }
            cout << n << endl;
        }
    }

int main()
{
   prima();
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int a[999999];
	a[0] = 2;
	long long k = 1;
	for (long long i = 2; i<=999999; i++)
	{
		int flag = 1;
		for (long long j = 2; j <= sqrt(i) + 1;j++)
		{
			if (i%j == 0)
			{
				flag = 0;
				break;
			}
		}
		if (flag)
			a[k] = i, k ++ ;
	}
	int n;
	while (cin >> n)
	{
		long long ans = 0;
		for (long long x = 0; x < k; x++)
		{
			if (n >= a[x])
				ans++;
			else
				break;
		}
		cout << ans << endl;
	}
	return 0;
}