Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

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

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

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

C++: #include <iostream>

int main()
{
    bool *table = new bool[1000000];
    while (true) {
        int n;
        std::cin >> n;
        if (std::cin.eof()) break;

        memset(table, 1, sizeof(bool) * (n + 1));
        for (int i = 2; i * i <= n; ++i)
            for (int j = 2; i * j <= n; ++j)
                table[i * j] = false;

        int cnt = 0;
        for (int i = 2; i <= n; ++i) cnt += table[i];
        std::cout << cnt << std::endl;
    }
    delete[] table;
}

C++: #include <iostream>
using namespace std;
const int MAX_N = 1000000;
int prime[MAX_N];
bool is_prime[MAX_N + 1];
int eratos(int n)
{
	int p = 0;
	for (int i = 0; i <= n; i++) is_prime[i] = true;
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= n; i++)
	{
		if(is_prime[i])
		{
			prime[p++] = i;
			for (int j = 2*i; j <= n; j += i) is_prime[j] = false; 
		}
	}
	return p;
}

int main()
{
	int n;
	while (cin >> n && n)
	{
		cout << eratos(n) << endl;
	}
	return 0;
}

C++: 
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#define pi 3.14159265358979323846264338
using namespace std;

int main() {
	int n;
	while (cin >> n) {
		vector<int> sos;
		sos.emplace_back(2);
		int s = 1;
		for (int j = 2; j <= n; j++) {
			for (int i = 0; i < sos.size(); i++) {
				if (j%sos[i] == 0) {
					break;
				}
				if (i == sos.size()-1) {
					sos.emplace_back(j);
					s++;
				}
			}
		}
		cout << s << endl;
	}
	return 0;
}

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

int CountPrime(int N);
int CheckPrime(int N);
bool IsPrime(int num);

int main()
{
	int N;

	while (std::cin >> N)
	{
		std::cout << CountPrime(N) << std::endl;
	}
}

int CountPrime(int N)
{
	int Counter = 0;

	for (int i = 1; i <= N; i++)
	{
		Counter = Counter + CheckPrime(i);
	}

	return Counter;
}

int CheckPrime(int N)
{
	if (IsPrime(N))
		return 1;

	return 0;
}

bool IsPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false; // ??¶??°????????????????????????


	double sqrtNum = std::sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			// ?´???°??§?????????
			return false;
		}
	}

	// ?´???°??§??????
	return true;
}

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

bool isprime(int n);

int main()
{
	while(1)
	{
		int n,count=0;
		std::cin>>n;
		if(std::cin.eof())break;
		for(int i=2;i<n;i++)
		{
			count+=isprime(i)?1:0;
		}
		std::cout<<count<<std::endl;
	}
	return 0;
}

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

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

int main() {
  int cnt[1000000];
  for (int i = 0; i < 1000000; ++i) cnt[i] = 0;
  for (int i = 2; i < 1000000; ++i) {
    bool is_prime = true;
    for (int j = 2; j*j <= i; ++j) {
      if ((i % j) == 0) {
        is_prime = false;
        break;
      }
    }
    cnt[i] = cnt[i-1];
    if (is_prime)
      ++cnt[i];
  }
  int n;
  while(std::scanf("%d",&n) != EOF) {
    std::cout << cnt[n] << std::endl;
  }
  return 0;
}

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


int main()
{

	int i,n,count,num;
	deque<int> sosu;
	deque<int>::iterator it;
	bool flg;
	
	//テーブルを予め作成する
	bool prime[1000000] = {false};
	
	prime[2] = true;

	for( i = 3; i <= 1000000 ; i+=2 ) {
		flg = true;	
		for(it = sosu.begin(); it != sosu.end(); it++ ) {
			num = *it;
			if( i < num * num ){
				break;
			}
			if( (i % num ) == 0 ){
				flg = false;
				break;
			}				
		}
		if( flg == true ) {
			sosu.push_back( i );
			prime[i] = true;	
		}
	}
	
	while(cin >> n){
		count = 0;
		if( n == 2 )
			count = 1;
		else if( n < 2 )
			count = 0;
		else {
			for( i = 3; i <= n ; i+=2 ) {
				if( prime[i] == true )
					count++;
			}
			count ++;
		}
		cout << count << endl;
	}
			
	return 0;
}

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


int main(){
	int number,cnt=0;
	cin>>number;
	int* arr = new int[number+1];
	for (int i = 1; i <= number; i+=2)
	{
		arr[i-1]=0;
		arr[i]=1;
	}
	for (int i = 3; i < sqrt(number); i+=2)
		if (arr[i])
			for (int j = i+i; j <=number; j+=i)
				arr[j]=0;
	arr[2]=1;arr[1]=0;
	for (int i = 0; i <= number; i++)
		if (arr[i])
			++cnt;
	cout<<cnt<<endl;
}

C++: #include <stdio.h>

int ans ;
int N ;
bool prime[1000200] ;

void SE ( ) ;

int main ( ) 
{
	SE ( ) ;
	while ( scanf ( "%d" , &N ) == 1 ) {
		ans = 0 ;
		if ( N > 2 ) {
			ans++ ;
		}
		for ( int i = 3 ; i < N ; i += 2 ) {
			if ( prime[i] == false ) {
				ans++ ;
			}
		}
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void SE ( )
{
	prime[0] = prime[1] = true ;
	for ( int i = 3 ; i < 1004 ; i += 2 ) {
		if ( prime[i] == false ) {
			for ( int j = i * i ; j < 1000020 ; j += i * 2 ) {
				prime[j] = true ;
			}
		}
	}
}

C++: #include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<set>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;


template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
	for (auto& e : t) fill_v(e, v);
}


#define ARRAY_MAX 100005
const int INF = INT32_MAX / 3;
const ll MOD = 1e9 + 7;

int dx[4] = { 1,0,0,-1 };
int dy[4] = { 0,1,-1,0 };


/******************************************************************************************/


/*nまでの素数を列挙して配列に保持*/
vector<ll> Eratosthenes(ll n) {

	vector<ll> arr(n);
	for (ll i = 0; i < n; i++) {
		arr[i] = 1;
	}
	arr[0] = arr[1] = 0;
	for (ll i = 2; i < sqrt(n); i++) {
		if (arr[i]) {
			for (ll j = 0; i * (j + 2) < n; j++) {
				arr[i * (j + 2)] = 0;
			}
		}
	}
	return arr;
}


int main() {

	int n;
	
	vector<ll> prime = Eratosthenes(1000005);

	for (int i = 0; i < prime.size()-1; i++)
	{
		prime[i + 1] += prime[i];
	}

	while (cin >> n) {
		cout << prime[n] << endl;
	}

	
	return 0;
}