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 <math.h>
int check_prime(int a)
{
   int c,b;
   b = (int)sqrt(a);
   for ( c = 2 ; c <=  b; c++ )
   {
      if ( a%c == 0 )
        return 0;
   }
      return 1;
}

int main ()
{
    int  n=0,i=0,prime=0,result=0;

   while( scanf("%d",&n) != EOF)
{
 for(i=2;i<=n;i++)
 {

   result = check_prime(i);

   if ( result == 1 )
     prime = prime +1;
 }
 printf("%d",prime);
 printf("\n");
 prime=0;
}
 return 0;
}

C++: #include<stdio.h>
int main(){
	int a,b,n;
	int p[80000];
	p[0]=2;
	n=1;
	for(a=3;a<1000000;a++){
		for(b=0;b<n;b++){
			if(a%p[b]==0){break;}
			if(a<p[b]*p[b]){
				p[n]=a;
				n++;
				break;
			}
		}
	}
		scanf("%d",&a);
		n=0;
		while(a>=p[n]){
			n++;
		}
		if(a<2){n=0;}
		printf("%d\n",n);
	return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool b[1000000];
int n,i,j,ans;
int GCD(int x,int y)
{
	return y==0?x:GCD(y,x%y);
}
void biao()
{
	for(i=2;i<=999999;i++)
	{
		if(b[i]==0)
		for(j=i+i;j<=999999;j=j+i)
			b[j]=1;
	}
}
int main()
{
	biao();
	while(~scanf("%d",&n))
	{
		ans=0;
		for(i=2;i<=n&&i<5;i++)
		{
			if(b[i]==0)
				ans++;
		}
		for(i=5;i<=n;i=i+6)
		{
			if(b[i]==0)
				ans++;
			if(b[i+2]==0&&i+2<=n)
				ans++;
		}
		printf("%d\n",ans);
	}
}

C++: #include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;

using namespace std;
/*int main(){
    
    ll n;
    while (cin>>n) {
        vector<ll> v;
        for(int i=0;i<n+1;i++){
            v.push_back(i);
        }
        ll b=v[v.size()-1];
        for(int i=2;i<=n;i++){
            ll j=2;
            while(i*j<=b){
                v[i*j]=0;
                j++;
            }
        }
        ll ans=0;
        for(int i=0;i<v.size();i++){
           // cout<<v[i]<<endl;
            if(v[i]!=0)ans++;
        }
        cout<<ans-1<<endl;
    }
    
    
    return 0;
}*/
int main(){
    
    ll n;
    while(cin>>n){
       /* ll ans=0;
        for(int i=3;i<=n;i+=2){
            int flag=0;
        for(int j=3;j<=sqrt(i);j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
    }
        cout<<ans+1<<endl;*/
        
        vector<bool> IsPrime;
        if(n+1>IsPrime.size()){
            IsPrime.resize(n+1,true);
        }
        IsPrime[0]=false;
        IsPrime[1]=false;
        for(int i=2;i<=sqrt(n);i++){
            if(IsPrime[i])
                for(ll j=2;i*j<=n;++j){
                    IsPrime[i*j]=false;
        }
        
        }
        ll ans=0;
        for(int i=0;i<IsPrime.size();i++){
            if(IsPrime[i])ans++;
        }
        cout<<ans<<endl;
        }
    
    return 0;
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int prime(int a)
{
	if(a<2)
	return 1;

	for(int i=2 ; (i*i)<=a ; i++)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	int pm[200000];
	int z=0;
	forin(i,2,1000000)
	{
		if(prime(i)==1)
		{
			pm[z]=i;
			z++;
		}
	}
	
	
	while(scanf("%d",&a)!=EOF)
	{
		int d=0;
		forin(i,0,z)
		{
			if(pm[i]>a)
			{
				d=i;
				printf("%d\n",d);
				break;		
			}
		}
	}
	return 0;
}

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

int main(){
  int isPrime[1000000];
  for(int i = 2; i < 100000 ; i++)isPrime[i] = 1;
  isPrime[0]  = isPrime[1] = 0; 
  for(int i = 2 ; i*i < 100000 ; i++ ){
    if(isPrime[i])for(int j = i*2 ; j < 100000 ; j+=i)isPrime[j] = 0;
}

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

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

int main(){
	bool prime[1000001];
	for(int i = 0; i < 1000001; i++) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	for(int i = 2; i < 1000; i++){
		for(int j = i*2; j < 1000001; j += i){
			prime[j] = false;
		}
	}

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