Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: //Prime Number
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<int> v;

int main(){
  ll n;
  v.push_back(2);
  for(ll i=3; i<1000000; i+=2){
    bool flag=true;
    for(vector<int>::iterator it=v.begin(); it!=v.end() && (*it)*(*it)<=i; it++){
      if(i%(*it)==0){
        flag=false;
        break;
      }
    }
    if(flag)v.push_back(i);
  }
  while(scanf("%lld", &n)!=EOF){
    ll ans=0;
    for(vector<int>::iterator it=v.begin(); it!=v.end(); it++){
      if(*it>n)break;
      ans++;
    }
    printf("%lld\n", ans);
  }
  return 0;
}

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

int isPrime(int n);

int main(){
  int n,out;
  while(cin >> n){
    out = 0;
    for(int i=2;i<=n;i++){
      if(isPrime(i)) out++;
    }
    cout << out << endl;
  }
  
}

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

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

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;
	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
		return true;
	}
}

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			if(prime(i))++a;
	}
		cout << a << '\n';
	}
}

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;
	while(scanf("%d",&a)!=EOF)
	{
		int d=0;
		forin(i,2,a+1)
		{
			if(prime(i)==1)
			d++;
		}
		printf("%d\n",d);
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		vector<int> v(n+1,1);
		for(int i=2; i<=sqrt(n); i++){
			for(int j=i+1; j<=n;j++){
				if(v[i]==1){
					if(j%i==0)
						v[j]=0;
				}
			}
		}
		for(int i=2;i<=n;i++){
			if(v[i]==1)
				cnt++;
		}
		cout << cnt << endl;
	}
}

C++: #include <stdio.h>

int main(){
	int s[1000000] = { 2, 3, 5 }, i, x, y = 3,n=0,z;
	
	while (scanf("%d", &n)!=EOF){
		z = 0; 
		for (i = 3; i < n + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % s[x] == 0)break;
				if (x + 1 == y){ s[y] = i, y++;}
			}
		}
		for (i = 0; i < y; i++){ if (s[i] > n)break; z++; }
		printf("%d\n", z);
	}
	return 0;
}

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

#define Max 999999

int main(){
	std::vector<bool>is_prime(Max+1,true);
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<=Max;i++){
		if(is_prime[i]){
			for(int j=i*2;j<=Max;j+=i)is_prime[j]=false;
		}
	}
	int n;
	while(std::cin>>n){
		int count=0;
		for(int i=2;i<=n;i++){
			if(is_prime[i])count++;
		}
		std::cout<<count<<std::endl;
	}
	return 0;
}

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

bool isPrime(int x) {
    if (x==2) {
        return true;
    }
    if (x<2 || x%2==0) {
        return false;
    }
    for (int i=3; i*i<=x; i+=2) {
        if (x%i==0) {
            return false;
        }
    }
    return true;
}
int main() {
    int n;
    int cnt;
    while (cin >> n) {
        cnt=0;
        for (int i=0; i<=n; i++) {
            if (isPrime(i)) {
                cnt++;
            }
        }
        printf("%d\n",cnt);
    }
    return 0;
}

C++: #include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <queue>
#include <map>
#include <fstream>
#include <array>
#include <utility>
#include <functional>

using namespace std;
typedef long long Int;
#define REP(i , x) for(int i = 0 ; i < x ; ++i)

typedef pair<int, int> P;

bool dp[1000000];

int main()
{
	int N;
	while (cin >> N){
		long ans(0);
		dp[0] = dp[1] = true;
		for (int i = 2; i <= N*N; ++i){
			if (!dp[i]){
				for (int j = 2*i; j <= N; j += i)
					dp[j] = true;
			}
		}
		for (int i = 2; i <= N; ++i){
			ans += !dp[i];
		}
		cout << ans << endl;
	}
}

C++: #include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

const int N = 100000;

int main(void)
{
    bool a[N];
    int prime[N], n, count = 0;
    rep(i,N)
    a[i] = true;
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }
    
    while(cin >> n)
    {
        rep(i,n+1)
        {
            if(a[i])
                count++;
        }
        cout << count << endl;
    }
    
    return 0;
}

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

int main(void){
int unti[1000000];
for(int n = 2;n < 10000000;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000000;a++)
{
	if((a * n ) < 1000000 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
	}
return 0;
}

C++: #include<bits/stdc++.h>
#define loop(i, a, b) for(int i = a; i < b; i++) 
#define rep(i, a) loop(i, 0, a)
using namespace std;
const int MOD = 1000000007;
const int inf = 1e8;
using vi = vector <int>;
using vvi = vector <vi>;
using vc = vector <char>;
using vvc = vector <vc>;
using vs = vector <string>;
using vvs = vector <vs>;
//g++ -std==c++14
//setprecision(10)
int prime[1000000];
void eratosthenes(){
    for(int i = 0; i < 1000000; i++)    prime[i] = 1;
    prime[0] = prime[1] = 0;
    for(int i = 0; i * i <= 1000000; i++)
        if(prime[i])
            for(int j = i * 2; j < 1000000; j += i)
                prime[j] = 0;
}

int main(){
    int n;
    eratosthenes();
    while(cin >> n){
        int ans = 0;
        rep(i, n + 1)if(prime[i])ans++;
        cout << ans << endl;
    }
}