Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

C++: #include<stdio.h>
#include<float.h>
#include<vector>



int makePrimenumbers(int a){
	int temp;
	
	if(a<ref_max)return 0;

	temp = ref_max;
	ref_max=a;
	int i,k,isp=1;

	for(k=temp;k<ref_max;k++){
		for(i=0;i<primes.size();i++){
			if(k%primes[i]==0){
				isp=0;
				break;
			}
		}
		if(isp==1){
			primes.push_back(k);
		}
		isp=1;
	}
	return 0;
}

int countprime(int a){
	int i;
	for(i=0;i<prime.size();i++)
		if(a<prime[i])
			break;
	return (i);
}

int main(void)
{
	vector<int> primes;
	int ref_max=2;
	int result;
	int a;
	while(scanf("%d",&a)!=EOF){
		makePrimenumbers(a);
		result = countprime(a);
		printf("%d\n",result);
	}
  return 0;
}

C++: #include <stdio.h>
 #include <string.h>
int main(void) {
    int n,i,c,k,prime[999999] = {0},t;
    for(i = 2; 999999 >= i; i++){
        if(!prime[i])
    		for(c = i*2; 999999 >= c; c += i)prime[c] = 1;
    }
    while(scanf("%d",&n) != EOF){
    	i = 0;
    for(c = 2; n > c; c++){
        	if(!prime[c]) i++;
        }
    printf("%d\n",i);
    }
     
    return 0;
}

C++: #include<cstdio>
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int x=0;
        for(int j=2;j<=n;j+=2){
            bool a=true;
            for(int i=3;i*i<n;i+=2){
                if(j==3)break;
                if(j%i==0){
                    a=false;
                    break;
                }
            }
            if(a)x++;
            if(j==2)j--;
        }

        printf("%d\n",x);
    }

    return 0;
}

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

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;

vi prime_count;
void sieve(int max){
    int count = 0;
    vector<bool> table(max + 1, true);
    table[0] = false;
    prime_count.push_back(0);
    table[1] = false;
    prime_count.push_back(0);
    for(int i = 2; i <= max; i++){
        if(table[i]){
            count++;
            for(int j = 2; i * j <= max; j++){
                table[i * j] = false;
            }
        }
        prime_count.push_back(count);
    }
}

int main(){
    int n;
    sieve(10000);
    while(cin>>n){
        cout << prime_count[n] << endl;
    }
    return 0;
}

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

#define long long long
const long N = 10000000;
bool np[N];
long p[N], pp=0;

void eratos() {
    np[0]=np[1]=true;
    for (long i=2; i*i<N; i++) if (!np[i])
        for (long j=i*i; j<N; j+=i) np[j]=true;
    for (int i=2; i<N; i++)
    if (!np[i]) p[++pp]=i;
}
main()
{
	eratos();
	long n,d=0;
do
{
d=0;
	cin>>n;
	for(long i=1;i<n;i++)
	if(p[i]>n)
	{cout<<i-1<<endl; 
	break;}
}while(1);
}

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;
for(int i=0;i<30;++i){
    scanf("%lld",&num);
    a=sieve(num);
    printf("%d\n",a);
}
return 0;
}

C++: int main(){
	int i , j , n , pn , cn=0;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
		cn++;
		if(cn>=30) break;
	}
	return 0;
}

C++: import math

def isPrime(n):
	if n==1: return False
	if n==2: return True
	for i in range(2,int(math.sqrt(n))+2):
		if n%i==0: return False
	return True

while True:
	a = input()
	if a=='EOF': break
	sum = 0
	for i in range(1,a+1):
		if isPrime(i)==True:
			sum+=1
	print sum

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define MOD(x) (x%(mod))
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

bool debug=false;
/*---------------------------------------------------*/

bool prime[1000000];
int ans[1000000];

void is_prime(){
  rep(i,1000000)prime[i]=true;
  prime[0]=prime[1]=false;
  REP(i,2,1000000){
    if(prime[i]==true){
      for(int j=i+i;j<1000000;j+=i)prime[j]=false;
    }
  }
  if(debug)rep(i,1000)if(prime[i])cout<<i<<endl;
}

void calc(){
  ans[0]=0;
  REP(i,1,1000000){
    ans[i]=ans[i-1]+prime[i];
  }
}

int main(){
  int n;
  is_prime();
  calc();
  while(cin>>n){
    cout<<ans[n]<<endl;
  }
  return 0;
}

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

int main(){
	int n;
	int sosu[100000];
	int snum;
	bool judge;

	sosu[0] = 2;

	while(cin >> n){
		snum = 0;
		for(int i = 3; i <= n; i++){
			judge = true;
			for(int j = 0; sosu[j]*sosu[j] <= i; j++){
				if(i%sosu[j] == 0){
					judge = false;
					break;
				}
			}
			if(judge == true){
				snum ++;
				sosu[snum] = i;
			}
		}
		if(n == 1){
			cout << 0 << endl;
		}else{
			cout << snum + 1 << endl;
		}
	}



	return(0);
}

C++: #include<cstdio>

bool isprime[1000000];

void eratos(){
	for(int i=0;i<1000000;i++){
		isprime[i] = true;
	}
	isprime[0] = isprime[1] = false;
	for(int i=2;i<=1000;i++){
		if(isprime[i] == true){
			int j = i + i;
			while(j < 1000000){
				isprime[j] = false;
				j = j + i;
			}
		}
	}
}

int main(void){
	int n;
	eratos();
	while(scanf("%d",&n) != EOF){
		int cnt = 0;
		for(int i=0;i<=n;i++){
			if(isprime[i] == true){
				cnt++;
			}
		}
		printf("%d\n",cnt);
	}
	return 0;
}

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

#define MAX 1000000
int prime[MAX];

int main()
{
	int number,count=0;
	prime[0] = prime[1] = 0;

	for(int i=2;i<MAX;i++)
	{
		prime[i] = 1;
	}
	for(int i=2;i<1001;i++)
	{
		if(prime[i])
		{
			for(int j=2*i;j<MAX;j += i)
			{
				prime[j] = 0;
			}
		}
	}

	while(cin >> number)
	{
		count = 0;
		for(int i=2;i<=number;i++)
		{
			count += prime[i];
		}
		cout << count << endl;
	}

	return 0;
}

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