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] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

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

C++: #include<stdio.h>
const int MAX_N = 1000000;
int n;
int num[MAX_N];
int ans=0;

int main(){

    for (int i = 2; i < MAX_N; i++){
        num[i] = 1;
    }
    for (int i = 2; i < MAX_N; i++){
        if (num[i] == 0) continue;
        for (int j = 2; i*j < MAX_N; j++){
            num[i*j] = 0;
        }
    }

    while(scanf("%d",&n) != -1){
        ans = 0;
        for(int i = 0; i < n+1; i++){
            if(num[i] == 1){
            ans++;
        }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

#define N 1000000L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = (long int) divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main()
{
    long long int n,i,j,k,l,number[1000000];

    while(scanf("%lld",&n)!=EOF)
    {
       if(n==0 || n==1) printf("0\n");
       else if(n==2) printf("1\n");
       else if(n==3) printf("2\n");
       else
       {
            k=sqrt(n);
            l=1;
            for(i=0;i<n;i++)
            {
                number[i]=i+1;
            }

            for(j=2;j<=k;j++)
            {
                for(i=1;i<n;i++)
                {
                    if(number[i]%j==0)
                    {
                        number[i]=0;
                    }
                }
            }
            for(i=1;i<n;i++)
            {
                if(number[i]!=0) l++;
            }
            printf("%lld\n",l);
        }
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,c=0;
	int flg=0;
	while(cin>>a){
		for (int A=2;A<=a;A++){
		flg=0;
			for (int B=2;B<=A;B++){
				b=A%B;
				if (A==B){
					c++;
					break;
				}
				if (b==0) break;
			}
		}
		cout<<c<<endl;
		c=0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

bool pr(int p){
    int x=2;
    while(x*x<=p){
        if(p%x==0){
            return false;
        }
        x++;
    }
    return true;
}


int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int ans=0;
        for(int i=2;i<=n;i++){
            if(pr(i)){
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

using namespace std;

const int N = 1000010;
bool isPrime[N];

void sieve(){
    for(int i=2;i<N;i++) isPrime[i] = true;
    for(int i=2;i*i<N;i++){
        if(not isPrime[i]) continue;
        for(int j=i*i;j<N;j+=i){
            isPrime[j] = false;
        }
    }
}

int main(){
    vector<int> C(N);
    sieve();
    C[0] = 0;
    for(int i=1;i<N;i++){
        if(isPrime[i]){
            C[i] = C[i-1] + 1;
        }else{
            C[i] = C[i-1];
        }
    }
    int n;
    while(cin >> n){
        cout << C[n] << endl;
    }
    return 0;
}

C++: #include <stdio.h>

#define MAX (100000)

int main(void)
{
	int prime[MAX + 1] = {1};
	int n;
	int ans;
	int i;
	char str[8];
	
	for (int i = 0; i <= MAX; i++){
		prime[i] = 1;
	}
	
	prime[0] = prime[1] = 0;
	i = 0;
	while (i * i <= MAX){
		while (prime[++i] != 1 && i * i <= MAX);
		//printf("%d ", i);
		for (int j = 2; j * i <= MAX; j++){
			//printf("%d\n", i * j);
			prime[i * j] = 0;
		}
	}
	
	while (fgets(str, 7, stdin)){
		sscanf(str, "%d", &n);
		
		ans = 0;
		for (int i = 2; i <= n; i++){
			if (prime[i] == 1){
				ans++;
			}
		}
	
		printf("%d\n", ans);
	}
	
	return (0);
}

C++: #include <iostream>
using namespace std;
int main(){
	int a,b,c=0;
	int flg=0;
	while(cin>>a){
		for (int A=2;A<=a;A++){
		flg=0;
			for (int B=2;B<=A;B++){
				b=A%B;
				if (A==B){
					c++;
					break;
				}
				if (b==0) break;
			}
		}
		cout<<c<<endl;
		c=0;
	}
	return 0;
}

C++: 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<stdio.h>


int main(){
	int n;
	bool data[10000000];

	int i,j;
	data[0]=data[1]=0;
	for(i=2;i<10000000;i++){
		data[i]=1;
	}

	for(i=0;i<10000000;i++){
		if(data[i]==1){
			for(j=i+i;j<1000000;j=j+i){
				data[j]=0;
			}
		}
	}


	while(scanf("%d",&n)!=EOF){
		j=0;
		for(i=0;i<n;i++){
			if(data[i]==1)j++;
		}
		printf("%d\n",j);
	
	}
	return 0;
}

C++: #include <iostream>
#include <cstring>
#include <cmath>
using namespace std;
bool isPr(int n);
int main(){
    int a[1000000],n;
    memset(a,0,sizeof(a));
    a[2]=1;
    for(int i=3;i<1000001;i++)
        a[i]=a[i-1]+isPr(i);
    while(cin>>n){
        cout<<a[n]<<endl;
    }
    return 0;
}
bool isPr(int n){
    for(int i=sqrt(n)+1;i>1;i--){
        if(!(n%i)){
            return 0;
        }
    }
    return 1;
}

C++: #include <stdio.h>

const int MAX_V=1000000;
int prime[MAX_V+1];//1?´???°,0?´???°??§??????
int sum[MAX_V+1];
int main(){
    int i,k,v;
    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?????\???????????°????´???°??§??????
            }
        }
    }
    for(i=0;i<MAX_V+1;i++){
        sum[i+1]=sum[i]+prime[i];
    }
    while(scanf("%d",&v)!=EOF){
        printf("%d\n",sum[v+1]);
    }
    return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
	int x = 1000000;
	int p[x],q[x];
	for(int i=2;i<x;i++) p[i] = 0;
	for(int i=2;i<x;i++){
		if(q[i]==0) for(int j=2;j<x/i;j++) q[i*j] = 1;
	}
	int c = -1;
	for(int i=2;i<x;i++){
		if(q[i]==0){
			c++;
			p[c] = i;
		}
	}
	int n;
	while(cin >> n){
		int a = 0;
		for(int i=0;i<c;i++){
			if(p[i]>n) break;
			a++;
		}
		cout << a << endl;
	}
}