Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

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

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

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

C++: #include <stdio.h>
#include <math.h>
#define MAX 1000000
//エラトステネスの篩
int main(){
    int mem[100000] = {2};
    bool list[MAX]={true,true};
    int set = 2,m = 1,j,x;
    while( set < sqrt( MAX )){
    	for( int i = set;i < MAX;i++ ) if( i % set == 0 ) list[i] = true;
    	for( int i = set;i < MAX;i++ ) if( list[i] == false ){ set = i,mem[m++] = i,list[i] = true;break; }
    }
    for( int i = set;i < MAX;i++ )if( list[i] == false ) mem[m++] = i;
    while( scanf( "%d",&x ) != EOF ){
        for( j = 0;mem[j] <= x && j < m;j++ );
        printf( "%d\n",j );
    }
    return 0;
}

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

int main() {
	int n, ans;
	while (cin >> n) {
		ans = 2;
		if (n == 2) { cout << "1" << endl; continue; }
		if (n == 3) { cout << "2" << endl; continue; }
		for (int i = 4; i <= n; i++) {
			if (i % 2 == 0 || i % 3 == 0) continue;
			if (i % 6 != 1 && i % 6 != 5) continue;
			for (int i = 5; pow(i, 2) <= n; i += 6)
				if (n % i == 0 || n % (i + 2) == 0) continue;
			ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

C++: /*-*-coding:utf-8-*-*/
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <iterator>
#include <cmath>
#include <stack>
#include <functional>
#include <iomanip>
using namespace std;

int main()
{
  int n;

  while(cin >> n, !cin.eof()) {
    int ans = 0;
    int flag = 0;

    if(n >= 2) ans++;    
    for(int i = 3; i <= n; i+=2) {
      for(int j = 3; j <= sqrt(i); j+=2) {
	if(i % j == 0) {
	  flag = 1;
	  break;
	}
      }
      if(flag == 0) ans++;
    }    
    cout << ans << endl;
  }
  
  return 0;
}

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

using namespace std;

void set_prime_number(bool* array, int num) {

  fill(array, array + num, true);
  array[0] = array[1] = false;
  for (int i = 2; i < num; i++) {
    if (!array[i]) continue;
    for (int j = i * 2; j < num; j += i) {
      array[j] = false;
    }
  }

}

int main() {
  bool prime_number[999999];
  int num;
  int nump=0;
  int cnt=0;

	while(scanf("%d",&num)!=EOF){
	  set_prime_number(prime_number,num);
	 for (int i = 0; i < num+1; i++) {
		 if (prime_number[i]){cnt++;}
	 }
	 printf("%d ",cnt);
	 cnt=0;
	}


  return 0;
}

C++: #include <iostream>
using namespace std;
const int MAX_V = 1000000;
int prime[MAX_V+1];
int pcount[MAX_V];
int main() {
    int i, k,a,sum=0;
    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?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}