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>
using namespace std;
#define MAX 1000000

int main()
{
	int n;
	int a[MAX];
	int counter;
	
	a[0] = 0;
	a[1] = 0;
	for (int i = 2; i < MAX; i++) {
		a[i] = 1;
	}
	
	int j = 2;
	while (j < MAX) {
		if (a[j] == 0) {
			j++;
		} else {
			for (int k = j *2; k < MAX; k += j)
				a[k] = 0;
			j++;
		}
	}
	
	while (cin >> n) {
		counter = 0;
		for (int i = 2; i <= n; i++)
			if (a[i])
				counter++;
		cout << counter << "\n";
	}
		
	return 0;
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    int c[max];
    int so=0;
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        if(b[i]=!0){
            for(int j=i+1; j<=max; j++){
                if(j%i==0){
                    b[j]=0;
                }
        }
        }
    }
    
    for(int i=0; i<=max; i++){
        if(b[i]!=0){
            c[so]=i;
            so++;
        }
    }
    
    
//    for(int j=0; j<num; j++){
//        cout<<a[j][0]<<"\n";
//    }
//    
//    for(int j=0; j<=so; j++){
//        cout<<c[j]<<"\n";
//    }
    
    
    
    
    for(int i=0; i<num; i++){
        for(int j=0; j<so; j++){
            if(c[j]<=a[i][0]){
                a[i][1]++;
            }else{
                j=so;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int prime[1000005],cur;
bool isprime[1000005];
int main()
{
	isprime[1]=1;
	for(int i=2;i<1000000;i++)
		if(!isprime[i])
		{
			prime[cur++]=i;
			for(long long j=1LL*i*i;j<1000000LL;j+=1LL*i)
				isprime[j]=1;
		}
	int n;
	while(~scanf("%d",&n))
		printf("%d\n",lower_bound(prime,prime+cur,n)-prime+(!isprime[n]));
	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
vector <int> wow(1000001);

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;

	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
	}
		return true;
}

int main(){

	for(int i = 0; i < 1000001; ++i){
	if(prime(i)){
					wow[i] = 1;
				}else{
					wow[i] = 2;
				}
	}


	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
		if(wow[i] == 1){
				++a;
			}
	}
		cout << a << '\n';
	}
}

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

int main()
{
	int n,i,j,count,pnum;
	while(cin >> n){
		/* ????????? */
		count=0;
		pnum=0;
		
		
		for(i=n; i>=2; i--){
			for(j=1; j<=i; j++){
				if(i%j==0) count++;	//i--????´???°?????°???????????????
			}
			if(count==2) pnum++;
			count=0;
		}
		cout << pnum << endl;
	}
	
	return 0;
}

C++: 
//  test.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;


int main(){
    long int j,s[1000000]={0},d=1,i,n,k;
    
    for(i=2;i<1000000;i++){
        if(s[i]==0){
            
            for(j=2;j*j<=i;j+=2){
                if(i%j==0)
                    break;
                if(j==2)
                    j=1;
            }
            
            
            if(j*j>i){
                d++;
                printf("%ld\n",i);
                if(i<1000){
                    for(k=2;k*i<1000000;k++){
                        s[k*i]=-1;
                    }
                }
            }
        }
        s[i] = d;
    }
    
    while(EOF != scanf("%ld",&n)){
        printf("%ld\n",s[n]-1);
    }
    
    
    return 0;
}

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

int main(){

  int n,i,j,ans;


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

    for(;n > 1 ; n--){
      if(n == 2 ) ans++;
      for(i = 2 ; i <= (int)sqrt((double)n) ; i++){
	if(n%i == 0){
	  break; 
	}
      }
      if(n%i != 0){
	ans++;
      }
    }
    cout << ans << endl;

  }
  return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
#define N 1000000
int p[N];
int main() {
	int i, j,n,cnt;
	for (i = 2; i <= sqrt(N); i++) if (!p[i]) for (j = i*i; j < N; j += i)p[j] = 1;
	while (cin >> n) {
		cnt = 0;
		for (i = 2; i <= n; i++) if (!p[i]) cnt++;
		cout << cnt << endl;
	}
	return 0;
}

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

int main(){
	int n;
	int a=0;
	cin >> n)
		for(int i = 0; i < n; ++i){
			for(int j = 2; j <= i; ++j){

				if(i%j == 0){
				if(i==j){
					++a;
				}else{
					break;
				}
				}
		}
	
	}
		cout << a << '\n';
}

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

bool IsPrime(int n) {
    for(int i = 2; i*i <= n; i++) {
        if(n % i == 0) {
            return false;
        }
    }
    return true;
}

int main() {
	// your code goes here
	int count = 0;
	int n;
	while(1){
		cin >> n;
		if(cin.eof()){
			break;
		}
	
		for(int i=2;i<=n;i++){
			if(IsPrime(i)){
				count++;
			}
		}
		cout << count << endl;
		count = 0;
		
	}
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int sieve(int n){
  int prime[1000000];
  bool is_prime[1000000];
  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++]=true;
      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<stdio.h>
int main(void)
{
    int n,i,j,z,x;
	
    
	while(scanf("%d",&n)!=EOF){
		for(i=2;i<=n;i++){
			z=0;
			for(j=2;j<i;j++){
				if(i%j==0){
					z++;
					break;
				}
			}
			if(z==0){
				x++;
			}
		}
		printf("%d\n",x);
		x=0;
	}
	return 0;
}