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++: #include <bits/stdc++.h>

using namespace std;

#define LOG(...) fprintf(stderr, __VA_ARGS__)
//#define LOG(...)
#define FOR(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REP(i, n) for(int i=0; i<(int)(n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define SQ(n) (n) * (n)

typedef long long ll;
typedef unsigned long long ull;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vb> vvb;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int MAX_VALUE = 1000007;
bool prime[MAX_VALUE];

int main() {
  FOR(i, 2, MAX_VALUE){
    if(prime[i]) continue;
    for(int j = i * 2; j<MAX_VALUE; j+=i)
      prime[j]=true;
  }

  int n;
  while(cin >> n) {
    int cnt = 0;
    FOR(i, 2, n + 1){
      if (!prime[i]) cnt++;
    }
    cout << cnt << endl;
  }
}

C++: #include <iostream>
using namespace std;
void solve(int n);

int main() {
	int n;
	while (cin >> n) {
		if (n<=1) cout << 0 << endl;
		solve(n);
	}
	return 0;
}
void solve(int n) {
	int prime[n];
	int i=0;j=0;
	for (i=2; i<=n; i++) {
		prime[j] = i;
		j++;
	}

	int p;
	for (i=0; i<n; i++) {
		p = prime[i];
		if (p == -1) continue;
		
		for (int k=i+1; k<n; k++) {
			if (prime[k]%p == 0)
				prime[k] = -1;
		}
	}
	int count = 0;
	for (int i=0; i<n; i++)
		if (prime[i] != -1) count++;
	cout << count << endl;
}

C++: #include <stdio.h>
#include <string.h>
int main(void){
    int n=9999,a,b,c;
    char x[1000000];
    memset(x,0,sizeof(x));
    for(a=2,c=0;a<=n;a++){
        if(x[a]){x[a]=c;continue;}
        x[a]=++c;
        for(b=a*2;b<=n;b+=a)x[b]=-1;
    }
    while(~scanf("%d",&n)){
        printf("%d\n",x[n]);
    }
    return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int yakusuu(int i){
	int counter=0;
	for (int j = 1; j <= i; j++){
		if (i%j == 0) counter++;
	}
	return counter;
}


int main()
{
	int n;
	
		
		while (scanf("%d",&n)!=-1)
		{
			int counter1 = 0;
			for (int i = 0; i <= n; i++)
			{
				if (yakusuu(i) == 2) counter1++;
			}

				cout << counter1 << endl;
		}
		
		
	return 0;
}

C++: #include <iostream>
using namespace std;
 
 bool IsPrime(int n){
    for(int i=2;i*i<=n;i++){
        if(n%i == 0){return false;}
    }
    return true;
}
 
 
int main(void) {
    int n;
 
    while(cin >> n){
    	for(i=2;i<=n;i++){
 　　		if(IsPrime(i)) count++;
 　	}
    	cout << count << endl;
    }
    
    return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i+1);
    }
    while ( cin >> a){
        sum =0;
        for (int i=1;i<a;i++){
            sum +=b[i];
        }
        cout << sum << endl;
    }
}
int prime(int x){
    if(x==1)
        return 0;
    if(x==2)
        return 1;
    for (int i=2;i<=sqrt(x)+1;i++){
        if(x%i==0)
            return 0;
    }
    return 1;
}

C++: #include <iostream>

using namespace std;

int main(void){
	int val;
	while(cin >> val)
		cerr << val << endl;

	return 0;
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    int c[max];
    int so=0;
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        for(int j=i+1; j<=max; j++){
            if(j%i==0){
                b[j]=0;
            }
        }
    }
    
    for(int i=0; i<=max; i++){
        if(b[i]!=0){
            c[so]=i;
            so++;
        }
    }
    
    
//    for(int j=0; j<num; j++){
//        cout<<a[j][0]<<"\n";
//    }
//    
//    for(int j=0; j<=so; j++){
//        cout<<c[j]<<"\n";
//    }
    
    
    
    
    for(int i=0; i<num; i++){
        for(int j=0; j<so; j++){
            if(c[j]<=a[i][0]){
                a[i][1]++;
            }else{
                j=so;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

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

int main(){
    int ans,n;
	while(1){
		ans=0;
		if(scanf("%d",&n)==EOF)break;
		if(n==1){
			cout<<0<<endl;
		}else{
			if(n>=2)ans++;
			if(n>=3)ans++;
			if(n>=5)ans++;
			if(n>=7)ans++;
			if(n>=9){
				for(int i=9;i<=n;i+=2){
			        int prime=1;
				    for(int k=3;k<=sqrt(i);k+=2){
					    if(i%k==0){
						    prime=0;
						    break;
    					}
					}
				    if(prime)ans++;
				}
			}
		cout<<ans<<endl;
		}
	}
}

C++: /*************************************************************************
	> File Name: aoj0009.cpp
	> Author: BMan
	> Mail: luo-kai-jia@163.com
	> Created Time: Wed 24 Oct 2018 08:50:17 PM CST
 ************************************************************************/

#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <limits.h>
#include <queue>
#include <math.h>
#include <iostream>

#define FOR(i, x, y) for (int i = x; i <= y; i++)
#define REPEAT(_N) for (int _i = 0; _i < _N; _i++)

using namespace std;

inline bool Read(int &a) { return scanf("%d", &a) != EOF; }

const int maxn = 1 << 20;
int p[maxn];
int Process() {
    p[0] = p[1] = 0;
    for (int i = 2; i < maxn; i++) p[i] = 1;
    for (int i = 2; i < maxn; i++) {
        if (!p[i]) continue;
        for (int j = i + i; j < maxn; j += i) {
            p[j] = 0;
        }
    }
    for (int i = 2; i < maxn; i++) {
        p[i] += p[i - 1];
    }
    int n;
    while (Read(n)) {
        printf("%d\n", p[n]);
    }
    return 0;
}

int main() {
    std::ios::sync_with_stdio(false);
    return Process();
}

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

int pri[1000000];
int sz;

void get_pri()
{
    sz=0;
    for(int i=2;i<=999999;i++)
    {
        int ok=0;
        for(int j=2;j*j<=i;j++)
            if(i%j==0){
                ok=1;
                break;
            }
        if(ok==0)
            pri[sz++]=i;
    }
}

int main()
{
    int n;
    get_pri();
    while(scanf("%d",&n)!=EOF)
    {
        int pos=lower_bound(pri,pri+sz,n)-pri;
        if(pri[pos]==n)
            printf("%d\n",pos+1);
        else
            printf("%d\n",pos);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,n[99999],j,o=0;
	for(int i=2;i<=99999;i++){
		for( j=2;j<i;j++){
			 if(i%j==0)break;
		}
		if(i == j)n[i]=1;
		else n[i]=0;
	}	
	cin>>a;
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
}