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 <bits/stdc++.h>
using namespace std;

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false


int prime[100000]={0};
int k=1;
void
 makeprime(int n)
{
    prime[0]=2;
    for (int i = 3; i < n; i++)
    {
        double temp = sqrt(i);
        for (int j = 0;; j++)
        {
            if (i % prime[j] == 0)
            {
                break; //this is no prime.
            }
            if (temp < prime[j])
            {
                prime[k++]=i;
                break;
            }
        }
    }
}

int main()
{
    makeprime(999999);
    int n;
    int ans=0,i;
    while(cin>>n){
        ans=0;
        i=0;
        while(true){
            if(prime[i]<=n){
                ans++;
            }
            if(n<prime[i]){
                break;
            }
            i++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

C++: #include <cstdio>
bool d[1000000];
int c[999999];
int main() {
    int i,j,r=0,n;
	for(i=4;i<=999999;i+=2)d[i]=true;
    for(i=2;i*i<=999999;i++) {
        if(d[i])continue;
        for(j=i*2;j<=999999;j+=i)d[j]=true;
    }
	for(i=1;i<999999;i++) {
		c[i]=c[i-1];
		if(!d[i+1])c[i]++;
	}
    while(scanf("%d",&n)!=EOF) {
        printf("%d\n",c[n-1]);
    }
}

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

bool d[1000000];

int main()
{
  int n;
  int ans;
  while(cin >> n)
  {
    n++;
    for(int i = 0; i < 1000000; i++)
      d[i] = false;
    d[0] = d[1] = true;
    ans = 0;
    for(int i = 2; i < n; i++)
    {
      if(d[i])
        continue;
      for(int j = i + i; j < n; j+= i)
        d[j] = true;
    }
    for(int i = 0; i < n; i++)
    {
      //cout << d[i] << endl;
      ans += !d[i] ? 1 : 0;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include<iostream>

typedef int moe;
typedef long lolita;
typedef char cuffs;
typedef float frill;
typedef double ruffle;
typedef void voile;
typedef unsigned tasogare;

#define katyusya const
#define apron volatile
#define pleats static
#define fancy virtual

using namespace std;

#define YUU 1000000

voile make_prime(moe n_prime[]){
  pleats moe is_prime[YUU];

  for( moe ai = 0; ai < YUU; ++ai )
    is_prime[ai] = 1;

  is_prime[0] = 0;
  is_prime[1] = 1;
  is_prime[2] = 1;

  for( moe ai = 2; ai < YUU; ++ai )
    if( is_prime[ ai ] )
      for( moe mai = 2; ai * mai < YUU; ++mai)
	is_prime[ ai * mai ] = 0;

  for( moe ai = 0; ai < YUU; ++ai )
    n_prime[ ai ] = 0;

  for( moe ai = 2; ai < YUU; ++ai ){
    n_prime[ ai ] = n_prime[ ai - 1 ];
    if( is_prime[ ai ] )
      n_prime[ ai ]++;
  }
}

moe main(voile){
  tasogare yuu;
  pleats moe n_prime[YUU];

  make_prime( n_prime );
  while(true){
    cin >> yuu;
    if( yuu == 0 || cin.eof() ) break;
    cout << n_prime[ yuu ] << endl;
  }

  return 0;
}

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

int judgeprime(long num){
  int primeflag=1,i;

  if(num%2==0){primeflag=0;}
  else for(i=3;i<sqrt(num);i+=2){

    if( num%i==0 ){
      primeflag=0;
      break;
    }

  }

  if(num==0||num==1||num==4){primeflag=0;}
  else if(num==2){primeflag=1;}

  return primeflag;

}

int main(void){
  long i,num;
  int much;

  while( scanf("%ld",&num) != -1 ){

    much=0;

    for(i=1;i<=num;i++){
      much+=judgeprime(i);
    }

    printf("%d\n",much);

  }

  return 0;  
}
04:57:02 ~/programming/AOJ 
$

C++: #include <iostream>

bool divisible( int u, int v )
{
    return (u % v) == 0 ? true : false;
}

int num_divisors( unsigned int start, unsigned int end )
{
    if ( start == end ) return 1;
    return divisible( end, start ) + num_divisors( start+1, end );
}

int no_of_divisor( unsigned int n )
{
    return num_divisors( 1, n );
}

bool is_prime( unsigned int n )
{
    return (no_of_divisor(n) == 2);
}

int count_prime( unsigned int n )
{
    int count = 1;
    for ( unsigned int i = 3; i <= n; i += 2 )
    {
        if ( is_prime(i) ) ++count;
    }
    return count;
}

int main()
{
    int n;
    while( std::cin >> n)
        std::cout << count_prime(n) << std::endl;
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;
	int N = 1000000;
	bool num[N] = true;
	num[0] = false;
	num[1] = false;
 	
	for(int i = 2; i*i <= N; i++){
		if(num[i]){
			for(int j = i; i*j < N; j++){
				num[i*j] = false;
			}
		}
	}
		
	while(cin >> n){
		for(int i = 1; i < n; i++) if(num[i]) cnt++;
		cout << cnt << endl;
	}
}

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(void){
	int count = 0;
	int n;
	cin >> n;
	for(int i=0; i<n; i++){
		int p;
		cin >> p;
		if(IsPrime(p)){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
 
int num[1000001];
 
void prime_num() {
  num[0] = 1;
  num[1] = 1;
  for ( int i = 2; i * i  < 1000001; i++ ) {
    if ( num[i] == 0 ) {
      for ( int j = i * 2; j < 1000001; j += i ) {
    num[j] = 1;
      }
    }
  }
}
 
int main() {
  int n;
  prime_num();
  while ( cin >> n ) {
    int cnt = 0;
    for ( int i = 2; i  <= n; i++ ) {
      if ( num[i] == 0 ) cnt++;
    }
    cout << cnt << endl;
  }
  return 0;
}

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

#define MAX_N 2000000
int prime[MAX_N];



int main(){
	prime[1] = 1;
	prime[2] = 0;
	prime[3] = 0;
	for(int i = 2; i<=MAX_N;i++){
		if(prime[i] == 0)
			for(int j=2*i;j<=MAX_N;j=j+i)
				prime[j] = 1;
	}
	
	int n;
	int num=0;
	while(true){
		if (cin.eof())
			break;
		cin >> n;

		for(int k = 1;k<=n; k++){
			if(prime[k]==0)
				num++;
		}
		cout << num << endl;
		num = 0;
	}
	return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int prime[1000000];
int main(){
    fill_n(prime,1000000,1);
    prime[0]=prime[1]=0;

    for(int i=2;i<1000000;i++){
        prime[i]+=prime[i-1];
        if(prime[i]==prime[i-1])continue;
        for(int j=i+i;j<1000000;j+=i)prime[j]=0;
    }

    int n;
    while(scanf("%d",&n)!=EOF)printf("%d\n",prime[n]);

    return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000;//1000000?????§????´???°??¨?????????
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>

using namespace std;

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