Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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

using namespace std;

typedef long long ll;

int main()
{
	ll n;
	vector<ll> pl;
	back_insert_iterator<vector<ll> > it(pl);
	
	cin>>n;
		//ú»
		pl.clear();
		//nª2ÈºÌÆ«Ì
		if(n < 2){
			cout<<0<<endl;
			return 0;
		}
		//â¿Ìì¬
		*it = 2;
		for(ll i = 3; i <= sqrt((long double)n); i++){
			for(ll t = 0; t < pl.size(); t++){
				if(i % pl[t] == 0) break;
				if(t == pl.size() -1) *it = i;
			}
		}
		//â¿É©¯é
		int L = pl.size();
		for(ll i = sqrt((long double)n) +1; i <= n; i++){
			for(ll t = 0; t < L; t++){
				if(i % pl[t] == 0) break;
				if(t == L -1) *it = i;
			}
		}
		cout<< pl.size() <<endl;
	
}

C++: #include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 999999;
bool p[MAX_N+1];
int sum[MAX_N+1];

void make_prime (void )
{
	fill (p, p+MAX_N+1, true );
	memset (sum, 0, sizeof (sum ) );
	p[0] = false;
	p[1] = false;
	for (int i = 2; i <= MAX_N; i++ ){
		if (p[i] ){
			for (int j = 2*i; j <= MAX_N; j += i ){
				p[j] = false;
			} // end for
		} // end if
	} // end for

	for (int i = 1; i <= MAX_N; i++ ){
		sum[i] = sum[i-1] + (p[i] ? 1 : 0 );
	} // end for
}

int main()
{
//	cut here before submit 
//	freopen ("testcase.PN", "r", stdin );
	make_prime ();

	int n;
	scanf ("%d", &n );
	printf ("%d\n", sum[n] );

	return 0;
}

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

using namespace std;

bool num[1000000] = { false };

void primNumberCheck(){
    num[2] = true;//?\???°?????????????????????????????????2???????????§???????????????

    int i, j, k;
    for (i = 3; i <= 1000000; i += 2)//2????????°???????????????
    {
        k = 0;
        for (j = 3; j <= sqrt((double)i); j += 2)//?????????i??\??????i????´???°??????????????\??????i????´???°??¨?????????????????§????????????
        {
            if (i%j == 0)
            {
                k = 1;
                break;
            }
        }
        if (k == 0)
        {
            num[i] = true;
        }
    }
}

int main()
{
    primNumberCheck();

    int n;
    
    while (cin>>n)
    {
        int result = 0;
        for (int i = 0; i <= n; i++)
        {
            if (num[i] == true)result++;
        }
        cout << result << endl;
    }

    return 0;
}

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

int main(){
    int max = 1000000;
    vector<int> prime(max, 1);
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < max; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= max; i++){
        if(prime[i] == 1){
            for(int j=i+i; j <= max; j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; i <= n; i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <stdio.h>
#include <iostream>
#define rep(i,n) for(int i = 2; i <= (n); ++i)
using namespace std;
int n;
bool p[1000000];
int main() {
	rep(i,1000) {
		int k = i;
		if(!p[k]) {
			while(k < 1000000) {
				k += i;
				p[k] = true;
			}
		}
	}
	while(scanf("%d\n", &n) != EOF) {
		int count = 0;
		rep(i,n) {
			if(!p[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
int p(long x)
{
    long i,j=sqrt(x),k=1;
    for(i=2;i<=(j);i++)
    {
        if(x%i==0){
            k=0;
            //return k;
        break;

        }
    }
    if(k==1)return 1;
    else return 2;
}
using namespace std;
int main()
{
    double a,b,c,i,n,s=0;

    cin>>n;
    //a=sqrt(n);
    for(i=2;i<=n;i++)
    {
        if(p(i)==1){s++;}
    }
    cout<<s<<endl;



    return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int d=0,i,j,s[100000],x;

	for(i=2;i<=100000;i++)
		s[i]=1;

	while((scanf("%d",&d))!=EOF)
	{
		x=0;
	    for(i=2;i<=d;i++){
	       if(s[i]==1){
		     for(j=i*2;j<=d;j+=i)
			   s[j]=0;
		   }
	    }  
		if(d<=1){
			printf("%d\n",0);
		}
		else
		{
		for(i=2;i<=d;i++){
			x+=s[i];
		}
		printf("%d\n",x);
		}
	}
  return 0;
}

C++: #include<cstdio>
#include<algorithm>
using namespace std;
int prime[1000005],cur;
bool isprime[1000005];
int main()
{
	for(int i=2;i<1000000;i++)
		if(!isprime[i])
		{
			prime[cur++]=i;
			for(long long j=1LL*i*i;j<1000000LL;j+=1LL*i)
				isprime[j]=1;
		}
	int n;
	while(~scanf("%d",&n))
		printf("%d\n",lower_bound(prime,prime+cur,n)-prime+(!isprime[n]));
	return 0;
}

C++: #include<iostream>

using namespace std;

#define rep(i, n) for (int i = 0; i < int(n); ++i)

const int MAX = 1000000;

bool prime[MAX];
int c[MAX];

int main() {
  rep (i, MAX) prime[i] = true;
  prime[0] = prime[1] = false;
  for (int i = 0; i * i <= MAX; ++i) {
    if (prime[i]) {
      for (int j = i * i; j < MAX; j += i) prime[j] = false;
    }
  }
  rep (i, MAX - 1) c[i + 1] = c[i] + (prime[i + 1] ? 1 : 0);
  int n;
  while (cin >> n) {
    cout << c[n] << endl;
  }
}

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

#pragma warning(disable:4996)

int main()
{
	int nCnt,nCnt2,In,Total,Count;

	Total = 0;

	scanf("%d", &In);

	for (nCnt = 2; nCnt <= In; nCnt++)
	{
		Count = 0;
		for (nCnt2 = nCnt; nCnt2 >= 2; nCnt2--)
		{
			if (nCnt%nCnt2 == 0)
			{
				if (nCnt != nCnt2)
					Count++;
			}
		}
		if (Count == 0)
			Total++;
	}

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

	return 0;
}

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

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	scanf("%d",&n);
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	
}

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];
		}
		printf("%d\n",count);
	}

	return 0;
}