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"

#define _USE_MATH_DEFINES
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

//#define int long long
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

bool isprime[1000000];
int ans[1000000];

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	rep(i, 0, 1000000)isprime[i] = true;
	isprime[0] = false;
	isprime[1] = false;
	ans[0] = ans[1] = 0;
	int n = 0;
	rep(i, 2, sqrt(1000000))
	{
		if (isprime[i])
		{
			n++;
			for (int j = 2 * i; j < 1000000; j += i)
			{
				isprime[j] = false;
			}
		}
		ans[i] = n;
	}

	int N;
	while (cin >> N)
	{
		cout << ans[N] << endl;
	}

	return 0;
}

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

int prime(int n){
  long long cnt=0,prime[n];
  bool f[n+1];
  for(int i=0;i<=n;i++){
    f[i]=true;
  }
  f[0]=f[1]=false;
  for(int i=2;i<=n;i++){
    if(f[i]){
      prime[cnt++]=i;
      for(int j=2*i;j<=n;j+=i){
        f[j]=false;
      }
    }
  }
  return cnt;
}

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

C++: #include<stdio.h>



int main(){
	int n,i,j;
	bool c[100000];
	int count;
	c[0]=c[1]=0;
	for(i=2;i<100000;i++){
		c[i]=1;
	}

	while(scanf("%d",&n)!=EOF){

		count=0;

		
		for(i=2;i<=n;i++){
			if(c[i]==1){
				for(j=i+1;j<=n;j++){
					if(j%i==0){
						c[j]=0;
					}
				}
				count++;
			}
		}

		printf("%d",count);


	}





	return 0;
}

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

int main()
{
	
	long int k,p[100000];
	float n;
	p[0]=2;
	while(cin>>n){
		if(n<0){
			break;
		}
	k=0;
	int r=(int)sqrt(n);
	for(int i=3;i<=r;i++){
		for(int j=0;j<k+1;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				p[k]=i;
			}
		}
	}
	int r_k=k;
	for(;r<n;r++){
		for(int i=0;i<=r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k){
				k++;
			}
		}
	}
	if(k!=0&&k!=1){
	cout<<k+1<<endl;
	}else{
		cout<<k<<endl;
	}
	}
}

C++: #include<iostream>

using namespace std;

int main()
{
    long int n;
    int i,k,j,b=0;

    cin >> n;
    if(1<=n<=999999)
    {
        for(i=2; i<=n; i++)
    {
        k = 1;
        for(j=2; j<=i/2; j++)
        {
            if(i%j==0)
            {
                k = 0;
                break;
            }
        }

        if(k==1)
        {
            b++;
        }
    }
    }

    cout << b << endl;

    return 0;

}

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

using namespace std;

int main()
{
	int n;
	int head,fin;
	int temp;
	
	
//	vector<int> isPrime;
	bool isPrime[1000000];
	
	while(cin>>n)
	{
		for(int i = 0; i < n; i++){
//			isPrime.push_back(1);
			isPrime[i] = 1;
		}
//		cout << "Corecced!" << endl;
		isPrime[0] = isPrime[1] = 0;
		temp = 0;
		
		for(;;)
		{
			//TõXgÌæªð©Â¯é
			for(head = temp+1; head < n; head++){
				if(isPrime[head] == 1){
					break;
				}
			}
			//æªðÜÜÈ¢{ÍSÄ¬
			for(int i = head; i*head < n; i++){
				isPrime[i*head] = 0;
			}
			//TõXgÌÅãÖ
			for(fin = n; fin > 0; fin--){
				if(isPrime[fin] == 1){
					break;
				}
			}
//			printf("head:%d    fin:%d\n",head,fin);
			
			if(fin < head*head){
				break;
			}
			temp = head;
		}
		
		int cont = 0;
		for(int i = 0; i < n; i++){
			if(isPrime[i] == 1){
				cont++;
			}
		}
		printf("%d\n",cont);
	}
}

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

int main(){
  int n;
  int num[1000000]={0};
  num[0]=1;
  num[1]=1;

  for(int i=2;i<1000000;i++){
    if(num[i]==0){
      for(int j=2;j*i<1000000;j++){
        num[j*i]=1;
      }
    }
  }

  while(scanf(" %d",&n)!=EOF){
    int cnt=0;
    for(int i=2;i<=n;i++){
      if(num[i]==0){
	cnt++;
      }
    }
    cout << cnt << endl;
  }

  return 0;
}

C++: #include <iostream>
using namespace std;
 
int main() {
	int N;
	bool is_prime[1000000];
	is_prime[0]=0; is_prime[1]=0;
	for(int i=2;i<1000000; i++){
		is_prime[i]=1;
	}
 
	for(int s=2; s<1000000; s++){
		if(is_prime[s]==1){	
		for(long long i=s*s; i<1000000; i+=s){
		is_prime[i]=0;	
 
		}
		}
	}
 
	while(cin >> N){
 
		int ans=0;
		for(int i=2; i<N+1; i++){
			ans+=is_prime[i];
		}
		cout << ans <<endl;
 
	}
return 0;
}

C++: /*
	大号水?，拿来?手
	靠，没仔?看?，明?需要素数打表
*/
#include<iostream>
#include<string.h>
#include<string>
#include<stdio.h>
#include<math.h>
#include<algorithm>
using namespace std;

int prime_table[1000000];

int Find_Number (int x)
{
	int cnt = 0;
	for (int i=2;i<=x;i++)
	{
		bool flag = false;
		for (int j=2;j<=sqrt((double)i);j++)
		{
			if ( i % j == 0)
			{
				flag = true;
				break;
			}
		}
		if (flag == false )
		{
			cnt++;
		}
		prime_table[i] = cnt;
	}
	return cnt;
}

int main ()
{
	int N;
	Find_Number (1000000);
	while (scanf("%d",&N)!=EOF)
	{
		cout<<prime_table[N]<<endl;
	}
	return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; 
int main(){
	int N;
	while(cin >> N)
	double p = std::log2(N);
	while (cin >> N){
		int sum =0;
		cout << N*p << endl;
	}
	return 0;
}

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

int main(){
	int n,s,a;
	
	while(cin >> n){
		a=0;
		for(int j=2;j<=n;j++){
			s=0;
			for(int i=2;i<j;i++){
				if(j%i==0){
					s++;
				}
			}
			if(s==0){
				a++;
			}
		}
		cout << a << "\n";
	}
		
	
return 0;
}

C++: #include<iostream>
#include<cstdio>
int cnt,n,prime[1000000];
using namespace std;

void getprime()
{
	int tt=0,flag;
	prime[tt++]=2;
	for(int i=3;i<=1000000;i++)
	{
		flag=1;
		for(int j=0;prime[j]*prime[j]<=i;j++)
		{
			if(i%prime[j]==0)
			{	
			    flag=0;
		     	break;
			}
		}
		if(flag==1) prime[tt++]=i;
	}
}

int main()
{	getprime();
	while(true)
	{
	   scanf("%d",&n);
	   if(n==1){
	   	printf("%d\n",0);
	   	continue;
	   }
       for(int i=0;i<1000000;i++){
       	if(prime[i]>n){
       		printf("%d\n",i);
       		break; 
		   }
	   }
    }
}