Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

C++: #include<iostream>

int main(){
  int prime[1000000]={0};
  int number[1000000];
  int k,n;

  number[1] = 0;

  for(int i=2;i<1000000;i++){
    if(prime[i]==0){
      for(int j=2;i*j<1000000;j++){
        prime[i*j] = 1;
      }
    }
    if(prime[i]==0){
      number[i] = number[i-1] + 1;
    }else{
      number[i] = number[i-1];
    }
  }
  while(std::cin >> n){
    std::cout << number[n] << std::endl;
  }
}

C++: #include<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    scanf("%d",&n);

	for(i=2;i<=n;i++){
        z=0;
		for(j=2;j<=i;j++){
		    if(i%j==0 && i!=j){
			    z++;
				break;
			}
		}
		if(z==0){
		    x++;
		}
	}
	printf("%d\n",x);
	return 0;
}

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

int main(){
	int t;
	while(cin >> t){
		cerr << t << endl;
	}
}

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

int main() {
	int n,i,j,ans;

	while(cin >> n){
	ans=0;
			for(i=2; i<=n; i++){
				for(j=2; j<=i; j++){
					if(i % j == 0 && i != j) break;
						if(i == j) ans++;
			}
		
		}
		cout << ans << endl;
	}

	return 0;
}

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

//素数かどうか判定する関数
bool judge( int x )
{

    for( int i = 2; i <= sqrt(x); i++ )       //与えられた数の平方根までに含まれる素数で
    {                                         //割り切ることが出来たらなら、その数は素数ではない
        if( x % i == 0)
            return false;
    }

    return true;
}

int main()
{
    int n;

    while( cin >> n )                           //2が素数であることを予め考慮
    {
        int count = 1;                          //countは素数の数なので、1

        if( n <= 1 )                            //nが1以下なら素数の数は0
        {
            count = 0;
        }

        for( int i = 3; i <= n; i += 2 )        //3以上の自然数について、奇数のみ素数判定を行う
        {
            if( judge(i) )
                count++;
        }

        cout << count << endl;
    }

    return 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;
}