Go: package main
import (
	"fmt"
	"os"
	"strconv"
	"bufio"
	//"math"
)

var sc = bufio.NewScanner(os.Stdin)

func main(){
	for sc.Scan(){
		n := nextInt()
		fmt.Println(calc(n))
	}
}

func calc(n int)int{
	// エラトステネスで数え上げる
	// 最初から999999まで用意しておいて入力のたびO(1)で出すのとどっちが速いのかはわからん
	eratos := make([]bool, n+1)
	c := 0
	for i:=2; i<len(eratos); i++{
		if eratos[i] == false{
			c++
			for j:=i*i; j<len(eratos); j+=i{
				eratos[j]=true
			}
		}
	}
	return c
}

func next()string{
	return sc.Text()
}

func nextInt()int{
	a, _ := strconv.Atoi(next())
	return a
}

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

int main(){

	int n,count;
	while(cin>>n){
		count=0;
		for(int i=2; i<=n; i++){
			int num = 0;
			for(int j=1; j<=i ;j++){
				if(i%j==0) num++;
			}
			if(num==2){
				count++;
			}
		}
		cout << count << endl;
	}
    return 0;
}

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

bool dec(int i, int prime[]) {
  for (int j = 0; prime[j] != 0; j++) {
    if (i % prime[j] == 0) {return false;}
  }
  return true;
}

int main() {
  int n;
  while (cin >> n) {
    int count = 0;
    int prime[1000000];
    for (int i = 0; i < 1000000; i++) {
      prime[i]=0;
    }
    if (n >= 2) {
      prime[0] = 2;
      count++;
    }
    for (int i = 3; i <= n; i += 2) {
      if (dec(i, prime)) {
	prime[count] = i;
	count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

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

signed main(){
  int p[100006];
  loop(i,2,100001){
    if(Is_Prime(i))p[i]=1;
  }
  rep(i,100001)p[i+1]+=p[i];
  int n;
  while(cin>>n){
    cout<<p[n]<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int N, i, j, H[1000001];
bool A[1000001];
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(A,true,1000000*sizeof(bool));
	A[1]=false;
	for (i=2;i<1000;i++) {
		if (A[i]) {
			for (j=i;j*i<1000000;j++) {
				A[i*j]=false;
			}
		}
	}
	H[1]=0;
	for (i=2;i<1000000;i++) {
		H[i]=H[i-1]+A[i];
	}
	while (cin>>N) {
		cout<<H[N]<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

vector<long long> primelist(long long n){
  vector<bool> prime(n+1,1);
  for(long long i = 2;i <= n;i++){
    if(prime[i]){
      for(long long j = 2*i;j <= n;j += i){
        prime[j] = 0;
      }
    }
  }
  prime[0] = 0;
  prime[1] = 0;
  vector<long long> primelist;
  for(long long i = 0;i <= n;i++)if(prime[i])primelist.pb(i);
  return primelist;
}

signed main(){
  int n;
  while(cin >> n){
    cout << primelist(n).size() << endl;
  }
}

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

using namespace std;

typedef long long ll;

int main()
{
	ll n;
	vector<ll> pl;
	back_insert_iterator<vector<ll> > it(pl);
	
	while(cin>>n){
		//ú»
		pl.clear();
		//nª2ÈºÌÆ«Ì
		if(n < 2){
			cout<<0<<endl;
			continue;
		}
		//â¿Ìì¬
		*it = 2;
		for(ll i = 3; i <= sqrt((long double)n); i++){
			for(ll t = 0; t < pl.size(); t++){
				if(i % pl[t] == 0) break;
				if(t == pl.size() -1) *it = i;
			}
		}
		//â¿É©¯é
		int L = pl.size();
		for(ll i = sqrt((long double)n) +1; i <= n; i++){
			for(ll t = 0; t < L; t++){
				if(i % pl[t] == 0) break;
				if(t == L -1) *it = i;
			}
		}
		cout<< pl.size() <<endl;
	}
}

C++: #include<iostream>
using namespace std;
bool arr[1000000];
int main()
{
	int n,p;
	cin>>n;
  	for(int i=2;i<=1000000;i++){
		if(arr[i]==0)
		{
		    p=i;
			for (int j=2;p*j<=1000000;j++)
			{
				arr[p*j]=1;
			}
		}
	}
	int count=0;
	for(int i=2;i<=n;i++){if(arr[i]==0)count++;}
	cout<<count<<endl;
	delete[] arr;
	return 0;
}

C++: #include <cstdio>

long MAX=999999;

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

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

bool mark [1000000];
 void sieve ()
 {
    int N = 1000000;
    memset (mark, true, N + 2);

    mark [0] = mark [1] = false;

    for ( int i = 4; i < N + 2; i += 2 )
        mark [i] = false;

    for ( int i = 3; i * i <= N + 2; i += 2 ) {
        if ( mark [i] == true ) {
            for ( int j = i * i; j < N + 2; j += 2 * i )
                mark [j] = false;
        }
    }
 }
int main()
{
    int n;
    sieve();
    while(scanf("%d",&n)!=EOF){
        int count = 0,i;
        for(i=2;i<=n;++i)
        {
            if(mark[i]==true)
                count++;
        }
        printf("%d",count);
   }
}

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


int main() {

//変数の宣言

	int i,n,j,sum,judge=1;
	
	while(cin>>n){
		sum = 1;
		for(i=3;i<n+1;i+=2){
			for(j=3;j<=sqrt(i);j+=2){
				if(i%j==0){
					judge = 0;
					break;
				}
			}
			if (judge==1){
				sum++;
			}
			judge = 1;
		}
		
		cout << sum <<endl;
	}

	return 0;
}

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

int main(){
	const int max_num=10000000;
	int prime[max_num];
	int prime2[max_num];
	int min_prime[168]={2 ,3 ,5 ,7 ,11 ,13 ,17 ,19 ,23 ,29 ,31 ,37 ,41 ,43 ,47 ,53 ,59 ,61 ,67 ,71 ,73 ,79 ,83 ,89 ,97 ,101 ,103 ,107 ,109 ,113 ,127 ,131 ,137 ,139 ,149 ,151 ,157, 163, 167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233 ,239 ,241 ,251 ,257 ,263 ,269 ,271 ,277 ,281 ,283 ,293 ,307 ,311 ,313 ,317 ,331 ,337 ,347 ,349 ,353 ,359 ,367 ,373 ,379 ,383 ,389 ,397 ,401 ,409 ,419 ,421 ,431 ,433 ,439 ,443 ,449 ,457 ,461 ,463 ,467 ,479 ,487 ,491 ,499 ,503 ,509 ,521 ,523 ,541 ,547 ,557 ,563 ,569 ,571 ,577 ,587 ,593 ,599 ,601 ,607 ,613 ,617 ,619 ,631 ,641 ,643 ,647 ,653 ,659 ,661 ,673 ,677 ,683 ,691 ,701 ,709 ,719 ,727 ,733 ,739 ,743 ,751 ,757 ,761 ,769 ,773 ,787 ,797 ,809 ,811 ,821 ,823 ,827 ,829 ,839 ,853 ,857 ,859 ,863 ,877 ,881 ,883 ,887 ,907 ,911 ,919 ,929 ,937 ,941 ,947 ,953 ,967 ,971 ,977 ,983 ,991 ,997 };
	int sosuu=0;
	int k=168;

	for(int i=0;i<168;i++){
		prime[i]=min_prime[i];
	}
	for(int i=1001;i<max_num;i+=2){
		sosuu=0;
		for(int j=0;j<168;j++){
			if(i%min_prime[j]==0){
				sosuu++;
			}
		}
		if(sosuu==0){
			prime[k]=i;
			k++;
		}
	}
	int l=0;
	for(int i=0;i<max_num;i++){
		if(i>=prime[l]){
			l++;
		}
		prime2[i]=l;
	}

	int n;

	while(cin>>n){
		cout<<prime2[n]<<endl;
	}

	return 0;
}

C++: #include	<stdio.h>

bool isPrimeNumber(int number){
	if(number	  == 2)	return true;
	if(number % 2 == 0)	return false;
	
	for(int i = 3; i <= sqrt(number) ;i += 2){
		if(number % i == 0)	return false;
	}
	
	return true;
}

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}