Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 3; i <= num; i += 2 { //1を除く入力値以下の数字
			for j := 3; j < i; j += 2 {
				if i%j == 0 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count + 1)
	}
}

C++: #include <iostream>
#include <math.h>
using namespace std;
int main() {
	unsigned long long int i;
	int n, p, cnt,fg;
	while (cin >> n) {
		i = 3;
		cnt = 1;
		fg = 0;	
		
		if ((int)log10(n) == 3) {
			cnt = 168;
			i = 1001;
		}
		else if ((int)log10(n) == 4) {
			cnt = 1229;
			i = 10001;
		}
		else if ((int)log10(n) == 5) {
			cnt = 9592;
			i = 100001;
		}
		if (110000<n) {
			cnt = 10453;
			i = 110001;
		}
		if (120000 < n) {
			cnt = 11301;
			i = 120001;
		}
		if (130000 < n) {
			cnt = 12159;
			i = 130001;
		}
		if (140000<n) {
			cnt = 13010;
			i = 140001;
		}
		if (150000<n) {
			cnt = 13848;
			i = 150001;
		}
		if (160000<n) {
			cnt = 14683;
			i = 160001;
		}
		if (170000<n) {
			cnt = 15493;
			i = 170001;
		}
		if (180000<n) {
			cnt = 16342;
			i = 180001;
		}
		if (190000<n) {
			cnt = 17170;
			i = 190001;
		}



		for (; i <= n; i+=2) {
			for (int j = 3; j <= (int)sqrt(i); j += 2) {
				if (i%j == 0) {
					fg = 1;
					break;
				}
			}
			if (fg)
				fg = 0;
			else
				cnt++;
		}
		if (n == 1)
			cnt--;
		cout << cnt << endl;
	}

	return 0;
}

C++: import math
import sys

def prime_calc(n):
    rootN = int(n**0.5)
    prime = [2]
    data = [i + 1 for i in range(2,n,2)]
    while True:
        p = data[0]
        if rootN <= p:
            return len(prime + data)
        prime.append(p)
        data = [e for e in data if e % p != 0]

def main():
    l = []

    for line in sys.stdin:
        l.append(line)        

    for line in l:
        print(prime_calc(line))

if __name__ == "__main__":
    main()

C++: #include<stdio.h>
int flg[1000000];
int main(void)
{

	int a,i,j,cnt;
	while(scanf("%d",&a)!=EOF){	
		for(i=2;i<=a;i++){
		flg[i]=1;
		}
		for(i=2;i*i<=a;i++){
			if(flg[i]=1){
				j=2;
				while(i*j<=a){
				flg[i*j]=0;
//				printf("i=%d j=%d a=%d\n",i,j,a);
				j++;
				}
			}
		}
//		for(i=2;i<=10;i++)	printf("flg=%d\n",flg[i]);
		cnt=0;
		for(i=2;i<=a;i++){
//		printf("i=%d\n",i);
			if(flg[i]==1){
//			printf("i=%d\n",i);
			
			cnt++;
			}
		}
		printf("%d\n",cnt);
	}	
	return 0;
}

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

void AOJ0009()
{
	int n = 0;
	int prime[10000];
	int count = 0;
	for (int i = 2; i <= 10000; i++)
	{
		int j = 2;
		bool flag = false;
		for (j = 2; j <= i; j++)
		{
			if (i % j == 0)
				break;
		}
		if (i == j)
		{
			prime[count] = i;
			count++;
		}
	}

	while (cin >> n)
	{
		count = 0;
		while (prime[count] <= n)
		{
			count++;
		}
		cout << count << endl;
	}
}
int main()
{
	//AOJ0005();
	//AOJ0007();
	AOJ0009();
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include<string>
#include<vector>
int main() {
	int n;
	while (std::cin >> n)
	{
		std::vector<bool> v(n + 1 ,false);
		int c = 0;
		v[0] = true, v[1] = true;
		for (int i = 2; i * i <= n ; ++i) {
			if (!v[i]) {
				for (int j = i * i; j <= n; j += i) {
					v[j] = true;
					++c;
				}
			}
		}

		std::cout << n-c-1 << std::endl;
	}
}

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

int main(){
int n;
cin >> n;
int a[n+1];
int b;
int c;
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
int d;
d=0;
b=2;
while(b<n+1){
if(a[b]==0){d=d+1; c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}}
b=b+1;}


cout << d;


}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
#include<string.h>
using namespace std;
const int N=11111;
vector<int> prime;
int sieve(long long n){
   bool arr[n+1];
   int cnt=0;
   memset(arr,true,sizeof(arr));
   for(int i=2;i<=n;++i){
    if(arr[i]){
        prime.push_back(i);
        cnt++;
    }
    for(int j=0;j<prime.size()&&i*prime[j]<n;j++){
        arr[i*prime[j]]=false;
        if(i%prime[j]==0)break;
    }
   }
   return cnt;
}

int main(){
long long num;
int a;
while(true){
    cin>>num;
    if(!num) break;
    a=sieve(num);
    printf("%d\n",a);
}
return 0;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int prime[80000];
	int ptr=2;
	prime[0] = 2;
	prime[1] = 3;
	for(int num=5; num<1000000; num+=2){
		bool f = false;
		for(int i = 0; i<ptr; i++){
			if (prime[i]*prime[i] > num) break;
			if (num%prime[i]==0) {
				f = true;
				break;
			}
		}
		if(!f) prime[ptr++] = num;
	}
	int n;
	while(cin >> n){
		int k=0;
		for(;prime[k]<=n;k++);
		cout << k << endl;
	}
	return 0;
}

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

using namespace std;

int main(void){
  int n;
  while(cin >> n){
    if(n==1){
      printf("%d\n",0);
      break;
    }
    int p[100000];
    p[0]=2;
    int pi=1;
    int i=2;
    while(i<=n){
      int t=1;
      int j;
      for(j=0;j<pi;j++){
	if(i%p[j]==0){
	  t=0;
	  break;
	}
      }
      if(t==1){
	p[pi]=i;
	pi++;
      }
      i++;
    }
    printf("%d\n",pi);
  }
  return 0;
}

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

class SOSU{
   public:
      int sosu(int);
};
int SOSU::sosu(int n){
   if(n==2)
      return 1;
   
   int i,j,z=1,flag;
   int ans = 1;
   int s[9999];
   s[0]=2;
   for(i=3;i<=n;i++){
      flag = 0;
      for(j=0;j<z;j++){
         if(i%s[j]==0){
            flag++;
            break;
         }
      }
      if(flag == 0){
         s[z] = i;
         z++;
         ans++;
      }
   }
   return ans;
}
int main(){
   SOSU Sosu;
   int n,ans;
   while(cin>>n){
      ans = Sosu.sosu(n);
      printf("%d\n",ans);
   }
   return 0;
}

C++: #include<iostream>
using namespace  std;
int primes[1000010];
bool isPrime(int p)
{
	bool flag = true;
	for (int i = 2; i * i <= p; i++)
	{
		if (p % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
int main()
{
	int n;
	for (int i = 0; i <= 999999; i++)primes[i] = 0;
	for (int i = 2; i <= 999999; i++)if (isPrime(i))primes[i] = 1;
	for (int i = 0; i <= 999999; i++)primes[i + 1] += primes[i];
	while (cin >> n)cout << primes[n] << endl;
	return 0;
}

C++: #include <stdio.h>

#define MAX 2000000
#define UNCHECKED 0
#define PRIME 1
#define COMPO 2


bool isPrime(int n);

int main(void){
    int n;
    int primes;
    
    while (scanf("%d", &n)!=EOF){
        primes = 0;
        for (int i=2; i<=n; i++){
            if (isPrime(i)) primes++;
        }
        printf("%d\n", primes);
    }
}

bool isPrime(int n){
    static int table[MAX]={0};
    static int minPrime=2;
    
    if (n<2) return 0;
    
    do{
        if (table[n] != UNCHECKED){
            return table[n] == PRIME ? 1 : 0;
        }
        table[minPrime] = PRIME;
        for (int i=2; i*minPrime<=MAX; i++){
            table[i*minPrime] = COMPO;
        }
        while (minPrime<=MAX && table[minPrime]!=UNCHECKED) minPrime++;
    }while(minPrime<=MAX);
}

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

void MakePrimeArray(bool A[],int n){
	A[0] = A[1] = false;
	for(int i=2;i<n;i++){
		A[i] = true;
	}
	
	for(int	i=2;i*i<n;i++){
		if(A[i]){
			for(int j=i*i;j<n;j+=i){
				A[j] = false;
			}
		}
	}
}

int main(){
	
	int n=1000000;

	bool primearray[n];
	
	MakePrimeArray(primearray,n);
	
	int NumPrimeArray[n];
	
	int count=0;
	for(int i=0;i<n;i++){
		if(primearray[i]){
			count++;
		}
		NumPrimeArray[i] = count;
	}
	
	while(true){
		int innum;
		cin >> innum;
		
		if(cin.eof()) break;
		
		cout << NumPrimeArray[innum] << endl;
	}
	
	return 0;
}