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 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 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>
const int MAX_V = 100;
int prime[MAX_V+1];
int main() {
  int i, k;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]) {
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }

  int right;
  int sum[MAX_V+1] = {0};
  sum[1] = 0;
  for(i = 1; i < MAX_V+1; i++){
    if(prime[i] == 1){
      sum[i + 1] = sum[i] + 1;
    }else{
      sum[i + 1] = sum[i];
    }
  }
  while(scanf("%d", &right) != EOF){
    printf("%d\n", sum[right + 1]);
  }
  return 0;
}

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

int prime[1000000];


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


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
 
  return 0;
}

C++: #include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

const int MAX_N = 100000000;
bool prime[MAX_N];
void eratos() {
	rep(i, MAX_N) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	REP(i, 2, sqrt(MAX_N)) {
		if (prime[i]) {
			for (int j = 0; i * (j + 2) < MAX_N; ++j) {
				prime[i * (j + 2)] = false;
			}
		}
	}
}

int main() {
	eratos();
	int n;
	while (cin >> n) {
		int ans = 0;
		for (int i = 2; i <= n; ++i) {
			if (prime[i]) ans++;
		}
		cout << ans << endl;
	}
}

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

int main()
{
	const size_t MAX = 1000000;

	bitset<MAX> primebox;
	primebox.set();
	primebox.reset(0);
	primebox.reset(1);

	for(int i = 2; i < MAX; i++)
	{
		if(!primebox.test(i))
			continue;

		for(int j = i*2; j < MAX; j += i)
			primebox.reset(j);
	}
		cout << "ok" << endl;

	size_t n;
	while(cin >> n)
	{
		int found;
		if(n < 2)
			found = 0;
		else if(n == 2)
			found = 1;
		else
		{
			found = 1;
			for(size_t i = 3; i <= n; i += 2)
				if(primebox.test(i))
					found++;
		}

		cout << found << endl;
	}

	return 0;
}

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

using namespace std;

int prime(int a){
    int sqt = sqrt(a);
    int array[a+1];
    array[1] = 1;
    array[2] = 0;
    array[3] = 0;
    if(a >= 4){
        for(int i = 2; i <= sqt; i++){
            for(int j = 2; j*i <= a; j++){
                array[i*j] = 1;
            }
        }
    }
    int count = 0;
    for(int i = 1; i <= a; i++){
        if(array[i] == 0) count++;
    }
    return count;
}

int main(){
    int n;
    while(cin >> n){
        cout << prime(n) << endl;
    }
}

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

int main(){

	const int N_MAX=1000000;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		so[i]=1;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	so[0]=so[1]=0;
	for(soi=0,i=2;i<=1000;i++){
		if(so[i]==0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=0;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

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

int main()
{
	int n, i, j, k=1, wareru=0,cnt;
	long int *sosu = (long int*)malloc(sizeof(long int) * 1000000);
	sosu[0] = 2;
	for (i = 3; i < 1000000; i += 2)
	{
		wareru = 0;
		for (j = 3; j <= sqrt(i*1.0); j += 2)
		{
			if (i%j == 0)
			{
				wareru = 1;
				break;
			}
		}
		if (wareru == 0)
		{
			sosu[k++] = i;
		}
	}

	while (scanf("%d", &n) != EOF)
	{
		if (n == 1)
		{
			printf("0\n");
			continue;
		}
		if (n == 2)
		{
			printf("1\n");
			continue;
		}
		for (i = 0; sosu[i] <= n; i++);
		printf("%d\n", i);
	}
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cassert>
#include<cctype>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<functional>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<set>
#include<stack>
#include<string>
#include<sstream>
#include<queue>
#include<vector>
using namespace std;

#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL

#define MAX 999999

//?´???°??????
bool isPrime(int x) {
	if (x < 2)return 0;
	else if (x == 2)return 1;
	if (x % 2 == 0)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}

//??¨????????????????????????
//n??\????????£??´??°????´???°???????????°???????????????is_prime[]???????´?
void eratos(int n, bool is_prime[]) {
	fill(is_prime, is_prime + n, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++) {
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j = j + i;
			}
		}
	}
}

int main() {
	bool is_prime[MAX];
	eratos(MAX, is_prime);

	for (int n; cin >> n;) {
		int cnt = 0;
		for (int i = 0; i <= n; i++) {
			if (is_prime[i])cnt++;
		}
		cout << cnt << endl;;
	}
	return 0;
}

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

using namespace std;

#define MAX_VALUE 1000000

int get_numprime( int num );

int main(void)
{
	int num;

	while(1)
	{
		cin >> num;
		if( cin.eof() ) break;
		int result = get_numprime( num );
		cout << result << endl;
	}

	return 0;
}

int get_numprime( int num )
{
	int numprime = 1; // 2はカウント済み

	bool erat[MAX_VALUE];

	for( int i = 0 ; i < MAX_VALUE ; i++ )
	{
		erat[MAX_VALUE] = true;
	}
	erat[0] = false; erat[1] = false;
	for( int i = 2 ; i <= num ; i++ )
	{
		if( erat[i] )
		{
			for( int j = i*2 ; j <= num ; j+=i )
			{
				erat[j] = false;
			}
		}
	}
	for( int i = 3 ; i <= num ; i+=2 )
	{
		if( erat[i] ) numprime++;
	}

	return numprime;
}

C++: #include <stdio.h>

using namespace std;

int calcLimit(int n){
	int limit;
	for(limit=0;limit*limit<=n;limit++);
	return limit-1;
}

int main(){
	int n,count,limit;

	while(scanf("%d",&n)!=EOF){
		count=0;
		int* array = new int[n+1];
		for(int i=1;i<=n;i++)array[i]=0;
		limit = calcLimit(n);
		for(int i=2;i<=limit;i++){
			if(array[i] == 0)
			{
				for(int j=2*i;j<=n;j+=i){
					if(array[j]==0){
						array[j]=1;
						count++;
					}
				}
			}
		}
		printf("%d\n",n-(count+1));
	}

    return 0;
}

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

int main() {
int b[100000];
for (int k=0;k<100001;k++){
	b[k]=0;
}
for (int p=2;p<100001;p++){
int i,a=0 ;
	i=2;
	while(i<p){
		if(p%i==0){
			break;
	}i=i+1;
	}
	if (i==p){
		a=1;
	}
	b[p]=a;
}
int c[100000];
for (int l=0;l<100001;l++){
	c[l+1]=c[l]+b[l+1];
}
int r;
while(cin>>r){
	cout<<c[r]<<endl;
}
	return 0;
}