Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

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

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

using namespace std;

int prime[100000];
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;
    cin>>n;
    cout<<sosuu(n)<<endl;
    return 0;
}

C++: #include <stdio.h>

int isprime(int n){
    for(int i = 2; i * i <= n; i++) {
        if(n % i == 0) return 0;  //素数でない
    }
    return 1; //素数である
}

int main() {
    int n;
    int ans[2] = {};
    while(scanf("%d", &n) != 0) {
        for(int i = n; i >= 5; i--) {
            if(isprime(i) == 1) {
                ans[0] = i;
                if(isprime(i - 2) == 1) {
                    ans[1] = i - 2;
                    break;
                }
            }
        }
        printf("%d %d", ans[0], ans[1]);
    }
}

C++: #include<stdio.h>

int main(void)
{
	int data,i,j,k=0,l=0,kai[100]={0},s[100000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai[k]=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai[k]+=1;
				}
			}
		}
		k+=1;
	}

  for(j=0;j<k;j++)
    printf("%d\n",kai[j]);
  return 0;
}

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

bool nonprime[1000000];

int main(){
	long i,j,n;
	for(i=2;i<=999999;i++){
		for(j=2;i*j<=999999;j++) nonprime[i*j]=1;
	}
	while(scanf("%ld",&n)!=EOF){
		j=0;//j?????????????????¨?????????????????????
		for(i=2;i<=n;i++) if(!nonprime[i]) j++;
		cout << j << endl;
	}
	return 0;
}

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

using namespace std;


int main(){
	int n;

	while(cin >> n){
		int ans=0;

		for(int number=2;number<=n;number++){
			int flag = 0;
			for(int i=2;i<number;i++){
				if(number%i==0){
					flag = 1;
					break;
				}
			}
			if(flag==0)ans++;
		}
		printf("%d\n",ans);
	}


	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define REP(i,N) for(int i = 0; i < (int)N; i++)

int main(){
	int max = 1000100;
	bool prime[1000100];
	int dp[1000000];
	prime[0] = prime[1] = false;
	int ret=0;
	memset(prime,true,sizeof(prime));
	memset(dp,0,sizeof(dp));
	int hako[30];
	memset(hako,0,sizeof(hako));
	REP(i,30) cin >> hako[i];
	for(int i=2;i<sqrt(max);i++)for(int j=i*2;j<max;j=j+i){
		prime[j] = false;
	}
	for(int i=1; i<max ;i++){
		dp[i]=dp[i-1];
		if(prime[i])dp[i]++;
	}
	REP(i,30)	cout << dp[hako[i]] << endl;
	return 0;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n , ans = 1;

	while(cin >> n){
		ans = 1;
		if(n == 0) break;

		if(n <= 1){
			ans--;
		}

		for(int i = 2; i <= n; i++){
			if(i % 2 != 0 && 9 > i){
				cout << i << endl;
				ans++;

			}if(i >= 9){
				if(i % 2 != 0 && i % 3 != 0 && i % 5 != 0 && i % 7 != 0){
					cout << i << endl;
					ans++;
				}
			}
		}

		cout << ans << endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <cmath>
#include <vector>
#include <time.h>     // for clock()
using namespace std;

/*
1???2 ?????? n ?????§?????´??°???????????????
2??????????????£???????????°????????§???????°?????????????????????? p ??¨?????????????????????????????????????????°?????? p ??¨?????????
p ??\?????? p ????????°?????¨????¶????????????????
3???2??????????????°?????????????????????p ??? ???n ????¶??????????????????????????????????????????£?????????????´???°???
*/
// ??¨????????????????????????
int SieveOfEratosthenes(int num) {
	
	if (num < 2) {
		return 0;
	}
	// num???????´???°?????°
	int count = 0;
	int i = 2;
	while (i <= num) {
		if (i == 2) {
			count++;
			i++;
			continue;
		}
		else if (i % 2 == 0) {
			//count++;
			i++;
			continue;
		}
		else {
			// Route Num?????´??°??¨??????????????????
			int routeN_int = (int)sqrt(i);
			int j = 3;
			while (i % j != 0) {
				if (j > routeN_int) {
					count++;
					break;
				}
				j += 2;
			}
			i++;
		}
	}


	return count;
}

int main() {

	int num = 0;
	while (cin >> num, num != 0) {
		//clock_t start = clock();    // ??????????????????
		cout << SieveOfEratosthenes(num) << endl;
		//clock_t end = clock();     // ????????????
		//std::cout << "duration = " << (double)(end - start) / CLOCKS_PER_SEC << "sec.\n";
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    max = sqrt(num) + 2;
    if(num == 2) return true;

    for(c=2; c < max; c++)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans;
    int buff;
    while(cin >> buff);
    {
        ans  = 0;
        for(int d =2; d <= buff; d++)
        {
            if(isprime(d)) ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <string.h>
#include <string>
#include <math.h>
#include <stack>
#include <algorithm> 
#include <limits.h>  

using namespace std;

int gcd(int a,int b){
	if(b==0){
		return a;
	}
	else{
		return gcd(b,a %b);
	}
	
	
//	return b==0?a:gcd(b,a%b);
}
int exgcd(int a,int b,int &d,int &x,int &y){
    if(b==0)
    {
        d=a;
        x=1; 
		y=0;
    }
    else
    {
        exgcd(b,a %b,d,y,x);     // xa+yb=d
//		y=(d-x*a)/b;
		y-=x*(a/b);
    }
}
int eular(int n){    //oulahanshu
    int ret=1, i;  
    for(i=2; i*i<=n; i++) {  
        if(n %i == 0) {  
            n /= i;  
            ret *= i-1;  
            cout<<"ret  "<<ret<<endl;
            while(n %i == 0) {  
                n /= i;  
                ret *= i;  
                cout<<"ret2  "<<ret<<endl;
            }  
        }  
    }  
    if(n>1)  
        ret *= n-1;  
    return ret;  
}  

int is_Prime(int n){
	int flag=1;
	for(int i=2;i<sqrt(n)+1;i++){
		if(n %i==0){
			flag=0;
			break;
		}
	}
	return flag;
}


int isprime[1000001]={};

void Eratosthenes(){
	memset(isprime,1,sizeof(isprime)/sizeof(int));
	isprime[0]=0;
	isprime[1]=0;
	for(int i=2;i<=1000;i++){
		if(isprime[i]){
			for(int j=2*i;j<1000000;j+=i){
				isprime[j]=0;
			}
		}
	}
}

int tab[1000001]={};

void maketable(){
	tab[0]=0;
	for(int i=1;i<1000000;i++){
		if(isprime[i]){
			tab[i]=tab[i-1]+1;
		}
		else{
			tab[i]=tab[i-1];
		}
	}	
}

int main(){
	
	Eratosthenes();
	
	maketable();
	
	int n;
	while(scanf("%d",&n)!=EOF){
		cout<<tab[n]<<endl;
	}
	
	
	return 0;
}