Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

C++: //TEMPLATE BEGIN
//#define ONLINE_JUDGE
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <cassert>
//#include <ctime>
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <functional>
#include <algorithm>
#include <complex>
#include <bitset>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
using namespace std;

#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); ++ (i))
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); -- (i))
#define FOREDGE(i, u, head, next) for (int (i) = (head[(u)]); (i); (i) = (next[(i)]))
#define FORSTL(it, A) for (__typeof((A).begin()) it = (A).begin(); it != (A).end(); ++ it)
#define CLR(a, b) memset((a), (b), sizeof (a))
#define CPY(a, b) memcpy((a), (b), sizeof (a))
#define DEBUG cerr << "debug" << endl
#define STAR cerr << "**********" << endl

#define RT return
#define BK break
#define CT continue
#define ALL(x) (x).begin(), (x).end()
#define HEAP priority_queue
#define st first
#define nd second
#define pf push_front
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define mp make_pair
#define re real()
#define im imag()

#define LIST0(A, n) {						\
	FOR (i, 0, n - 1) printf("%d ", A[i]);	\
	printf("\n");							\
}											\

#define LIST1(A, n) {						\
	FOR (i, 1, n) printf("%d ", A[i]);		\
	printf("\n");							\
}											\

#define SHOW0(A, n, m) {					\
	FOR (i, 0, n - 1) {						\
		FOR (j, 0, m - 1)					\
			printf("%d ", A[i][j]);			\
		printf("\n");						\
	}										\
}											\

#define SHOW1(A, n, m) {					\
	FOR (i, 1, n) {							\
		FOR (j, 1, m)						\
			printf("%d ", A[i][j]);			\
		printf("\n");						\
	}										\
}											\

typedef long long LL;
typedef double DB;
typedef long double LDB;
typedef unsigned int UINT;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<DB> VB;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef map<int, int> MII;
typedef map<LL, LL> MLL;
typedef map<int, string> MIS;
typedef map<string, int> MSI;

const int INF(0x3f3f3f3f);
const LL LINF(0x3f3f3f3f3f3f3f3fLL);
const DB DINF(1e20);
const DB EPS(1e-12); //adjustable
const DB PI(acos(-1.0));

inline DB cot(DB x) { RT 1.0 / tan(x); }
inline DB sec(DB x) { RT 1.0 / cos(x); }
inline DB csc(DB x) { RT 1.0 / sin(x); }

template<class T> inline T max(T a, T b, T c) { RT max(max(a, b), c); }
template<class T> inline T max(T a, T b, T c, T d) { RT max(max(a, b), max(c, d)); }
template<class T> inline T min(T a, T b, T c) { RT min(min(a, b), c); }
template<class T> inline T min(T a, T b, T c, T d) { RT min(min(a, b), min(c, d)); }

template<class T> inline void Scan(T& x) { //int, LL
    char c;
    for (c = getchar(); c <= ' '; c = getchar()) ;
    bool ngt(c == '-');
    if (ngt) c = getchar();
    for (x = 0; c > ' '; c = getchar()) x = (x << 3) + (x << 1) + c - '0';
    if (ngt) x = -x;
}
template<class T> inline void Scan(T& x, T& y) { Scan(x), Scan(y); }
template<class T> inline void Scan(T& x, T& y, T& z) { Scan(x), Scan(y), Scan(z); }
//TEMPLATE END

int cntp, prime[100010];
bool vis[1000010];

void Init() {
	FOR (i, 2, 999999) {
		if (!vis[i]) prime[++ cntp] = i;
		for (int j = 1; j <= cntp; ++ j) {
			if (i * prime[j] >= 1000000) BK;
			vis[i * prime[j]] = true;
			if (!(i % prime[j])) BK;
		}
	}
	prime[++ cntp] = INF;
}

int n;

void Main() {
	Init();
	while (cin >> n) cout << upper_bound(prime + 1, prime + cntp + 1, n) - prime - 1 << endl;
}

int main() {
	Main();
    RT 0;
}
//imagasaikou!

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

int main(){
    int n, ans = 0;
    bool judge = true;
    while(cin >> n){
        for(int i = 2; i <= n; i++){
            for(int j = 2; j < i; j++){
                if(i % j == 0){
                    judge = false;
                    break;
                }
            }
            if(judge)
                ans++;
            else
                judge = true;
        }
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}

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

int main()
{
	int n, x = 0;
	int countdata[1000];
	while (cin >> n) {
		int count = 0;
		for (int a = 2; a <= n; a++) {
			if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0 || a==2 || a==3 || a==5 || a==7) {
				count++;
			}
		}
		countdata[x] = count;
		x++;
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
}

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

int main(void) {
    int N=999999;
    int p[N] , s[N];
    p[0]=0;
    for (int i=1; i<N; i++){
        p[i] = 1;
        s[i] = 0;
    }
    for (int i=1; i<N; i++){
        if (p[i]==1){
            int n=i+1 , m=2*n;
            while (m<=N){
                p[m-1] = 0;
                m += n;
            }
        }
    }
    
    for (int i=1; i<N; i++){
        s[i] = s[i-1]+p[i];
    }
    int n;
    while (1){
        cin >> n;
        cout << s[n-1] << endl;
    }
    return 0;
}

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

int whether(int num);
int count(int num);

int main(){
	int n=1;
	int a=0;

	while(a==n){
	scanf("%d",&n);
	a = count(n);
	printf("%d\n",a);
	a=n;
}
	return 0;
}

int whether(int num){
	int s=sqrt(num);
	int i;
	for(i=3; i<=s; i+=2){ if(num%i==0) return 0; }

	return 1;
}

int count(int num){
	int a=1;
	int i;
	if(num <2){ return 0; }
	for(i=3; i<=num; i+=2){
		a += whether(i);
	}

	return a;
}

C++: #include <bits/stdc++.h>
using namespace std;
const int maxn=1e6;
#define ll long long
int pri[maxn];int vis[maxn];int rec[maxn];int op=0;int t;
void advan(){
     vis[1]=1;
     for(ll i=1;i<=1e6;i++){
        rec[i]=op;if(vis[i])continue;
        vis[op++]=1;rec[i]=op;
        for(ll j=i*i;j<1e6;j=j+i){
            vis[j]=1;
}}}
int main(){
    advan();int n;
    while(scanf("%d",&n)!=EOF){
        printf("%d\n",rec[n]);
    }
}

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

bool sieve[1000000];
void makesieve();

int main()
{
	makesieve();
	while(1)
	{
		int n,ans=0;
		std::cin>>n;
		if(std::cin.eof())break;
		for(int i=0;i<n;i++)
		{
			ans+=sieve[i]?1:0;
		}
		std::cout<<ans<<std::endl;
	}
	return 0;
}

void makesieve()
{
	memset(sieve,-1,sizeof(sieve));
	sieve[0]=false;sieve[1]=false;
	for(int i=2;i<1000000;i++)
	{
		for(int j=i*2;j<1000000;j+=i)
		{
			sieve[j]=false;
		}
	}
}

C++: #include <bits/stdc++.h>

using namespace std;

bool isprime(int p) {
    if (p == 1) return false;
    for (int i = 2; i < p; i++) {
        if (p%i == 0) return false;
    }
    return true;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n; cin>>n;
    int cnt=0;
    for(int i=1; i<=n; i++)
    {
        if(isprime(i)) ++cnt;
    }
    cout<<cnt<<endl;
}

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

using namespace std;


vector<int> era(int n){
	vector<int> prime;
	bool *is_prime = new bool[n+1];
	fill(is_prime,is_prime+n+1,true);
	is_prime[0] = is_prime[1] = false;
	for(int i = 2; i <= n; i++){
		if(is_prime[i]){
			prime.push_back(i);
			for(int j = i*2; j <= n; j+=i){
				is_prime[j] = false;
			}
		}
	}
	delete []is_prime;
	return prime;
}

int main(){

	int n;
	cin >> n;

	vector<int> p = era(n);
	cout << p.size() << endl;

	return 0;
}