Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

C++: #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define digit(N) cout << fixed << setprecision((N))

vector<int> eratosthenes(int N)
{
	vector<int> res;
	vector<bool> prime(N + 1, 1);
	prime[0] = prime[1] = false;
	for (int i = 2; i * i <= N; ++i)
	{
		if (prime[i] == true)
		{
			for (int j = 2 * i; j <= N; j += i)
			{
				prime[j] = false;
			}
		}
	}
	for (int i = 0; i <= N; ++i)
	{
		if (prime[i] == true)
			res.push_back(i);
	}
	return res;
}

int main()
{
	auto prime = eratosthenes(1000001);

	int N;
	while (cin >> N)
	{
		int index = 0;
		while (index < prime.size() && prime[index] <= N)
			index++;
		cout << index << endl;
	}
}

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

int CheckNum(int input){
	int count = 0;

	for(int i = 2; i < input; ++i){
		for(int j = 2; j < i + 1; ++j){
			if( i % j == 0){
				if(!(i == j)) break;
				++count;
			}
		}
	}
	return count;
}

int main () {
	int input;

	cin >> input;
	cout << CheckNum(input) << '\n';

	return 0;
}

C++: #include <stdio.h>
int main(){
    bool prime[1000000];
    int n,ans;
    prime[2]=true;
    for(int i=3;i<1000000;i+=2)prime[i]=true;
    for(int i=3;i<=1000;i+=2){
        if(prime[i]){
            for(int j=i*i;j<1000000;j+=i)
                prime[j]=false;
        }
    }
    while(scanf("%d",&n)!=EOF){
        ans=0;
        if(n<3){printf("%d\n",n-1);
            continue;}
    for(int i=3;i<=n;i+=2)if(prime[i])ans++;
        printf("%d\n",ans);
    }
}

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

int main(){
	bool is_prime[1000000];
	
	is_prime[0]=is_prime[1]=false;
	for(int i=2;i<1000000;i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_prime[j]=false;
				}
			}
		}
		
		int n_prime[1000000];
		
		int cnt=0;
		for(int i=0;i<1000000;i++){
			if(is_prime[i]){
				cnt++;
			}
			n_prime[i]=cnt;
		}
		
		while(true){
			int n;
			cin>>n;
			if(cin.eof())
				break;
				
			cout<<n_prime[n]<<endl;
		}
		
		return 0;
}

C++: #include<iostream>
using namespace std;
int n,p[1000000];
main(){
	for(int i=0;i<1000000;++i)p[i]=1;
	p[0]=0;
	p[1]=0;
	for(int i=2;i<1000000,i*i<1000000;++i){
		for(int j=2;j<1000000;++j){
			if(p[i]==0)break;
			if(j%i==0 && i!=j)p[j]=0;
		}
	}
	while(cin>>n){
		int sum=0;
		for(int i=0;i<=n;++i)if(p[i]==1)++sum;
		cout<<sum<<endl;
	}
}

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<i;j+=2){
            if(i%j==0){
                flag=1;
                break;
            }
        }
            if(flag==0){
                ans++;
            }
    }
        cout<<ans+1<<endl;
        }
    
    
    
    
    
    
    return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <cmath>
#include <algorithm>
using namespace std;


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

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

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

int table[1000000];

using namespace std;

void init() {
	for (int i = 0; i < 1000000; i++)
		table[i] = 0;
	for (int i = 2; i < 1000000; i++) {
		if (table[i] != -1) {
			table[i] = table[i-1]+1;
			for (int j = i+i; j < 1000000; j+=i)
				table[j] = -1;
		} else {
			table[i] = table[i-1];
		}
	}
}

int main(void) {
	int n;
	init();
	while (cin >> n) {
		cout << table[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
using namespace std;

int main(){
  int n;
  int i,j,k;
  int era;

  while(cin >> n){
    int count = 0;
    int S[n+1];
    for(i=2 ; i<n+1 ; i++){
      S[i] = i;
    }

    for(i=2 ; i<(
                 (int)sqrt(n)+1) ; i++){
      if(S[i] != 0){
        era = S[i];
        for(j=2 ; (j*era)<(n+1) ; j++){
          S[j*era] = 0;
        }
      }
    }

    for(i=2 ; i<n+1 ; i++){
      if(S[i] != 0){
        count++;
      }
    }
      
    cout <<  count << endl;
  }

    
  return 0;
}