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 <stdio.h>

int main(int argc, const char * argv[])
{
    int i, j, k, n, count;
    int a[999999];
    
    count = 0;
    
    while(scanf("%d",&n) != EOF){
        if (count == 0) {
            if (n > 1) {
                a[count++] = 2;
                if (n > 2) {
                    a[count++] = 3;
                    for(i=5; i<=n; i+=2){
                        k=0;
                        for(j=0; a[j]*a[j] <= i; j++){
                            if(i%a[j] == 0) {
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0) {
                            a[count++] = i;
                        }
                    }
                }
            }
            printf("%d\n",count);
        } else {
            if (n <= a[count - 1]) {
                for (i=count - 1; n < a[i]; i--);
                printf("%d\n", i+1);
            } else {
                if (a[count-1] == 2) {
                    a[count++] = 3;
                    printf("%d\n",count);
                } else {
                    for(i=a[count - 1]+2; i<=n; i+=2){
                        k=0;
                        for(j=0; a[j]*a[j] <= i; j++){
                            if(i%a[j] == 0) {
                                k = 1;
                                break;
                            }
                        }
                        if (k == 0) {
                            a[count++] = i;
                        }
                    }
                    printf("%d\n", count);
                }
            }
        }
        for (i=0; i<count; i++) printf("%d ",a[i]);
        printf("\n");
    }
    return 0;
}

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

using namespace std;

#define N 100000

int main(){

    bool primes[N];
    int  n; 

    fill(primes, primes + (sizeof primes / sizeof *primes), true);
   
    primes[0] = false;
    primes[1] = false;
    
    for(int i = 2; i < N; ++i){
        if(primes[i]){
            for(int j = i + i; j < N; j += i)primes[j] = false;
        }
    }

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

C++: #include<iostream>

using namespace std;

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

int main(void)
{
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(sosu(i))
				ans++;
		}
		cout<<ans<<endl;
	}
}

C++: #include <stdio.h>

char num[1000050];

void check(void)
{
	int i, j;
	
	num[0] = 1;
	num[1] = 1;
	num[2] = 0;
	
	for (i = 2; i < 1000000; i++){
		if (num[i] == 0){
			j = 2;
			while (i * j < 1000000){
				num[i * j] = 1;
				j++;
			}
		}
	}
}
		
int main()
{
	int i, n, sum;
	
	check();
	
	while (scanf("%d", &n) != EOF){
		
		sum = 0;
		
		for (i = 0; i <= n; i++){
			
			if (num[i] == 0)
			sum++;
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


int f(int a){
	if(a==1) return 0;
	for(int i=2;i<=sqrt((double)a);i++){
		if(!(a%i)){
			return 0;
		}
	}
	return 1;
}
bool solve(){
	int n;
	int nmax=0;
	vector<int> k;
	while(cin>>n){
		k.push_back(n);
		if(nmax<n) nmax = n;
	}
	
	vector<int> res(nmax+1);
	int cnt=0;
	for(int j=2;j<=nmax;j++){
		cnt += f(j);
		res[j] = cnt;
	}	
	for(int i=0;i<k.size();i++){
		cout<< res[k[i]]<< endl;
	}
		
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

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

bool prime(int n);

int main(void) {
	using namespace std;
	int x;
	int count;
	while (cin >> x) {
		count = 0;
		for (int i = 2; i <= x; i++) {
			if (prime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

bool prime(int n) {
	if (n % 2 == 0 && n != 2) {
		return false;
	}
	else {
		for (int i = 3; i <= pow((double)n, 0.5); i+=2) {
			if (n % i == 0)return false;
		}
	}

	return true;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(void){
int unti[1000002] = {0};
fill(unti,unti + 1000001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000001;a++)
{
    if((a * n  ) < 1000001 ) unti[a * n]++;
}
}
}
int b;
for(int i;i <= 31;i++){
cin >> b

int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
}
return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

	int primeNum[NUM];
	for(int i=0,c=0;i<NUM;i++){
		prime[i]&&c++;
		primeNum[i] = c;
	}
	for(int n;cin>>n;cout<<primeNum[n]<<endl);
}

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

int main(){
int n,a;
int ans;
while(cin>>n){
for(int i=2;i<n+1;i++){
for(int j=2;j*j<i+1;j++){
a=i%j;
if(a==0){ans++; break;}
}}
cout<<ans<<endl;}}

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

void extendPrim(vector<int> &prims,int n){
	if(prims.back()>=n)return;
	int i = prims.back();
	while(i++ <=n){
		for(auto it=prims.begin();it!=prims.end();it++){
			if(i % *it==0){break;}
			if(*it * *it > i){prims.push_back(i);break;}
		}
	}
}

int main(){
	vector<int> vec={2};
	//extendPrim(vec,100);
	int n;
	
	while(cin>>n){
		extendPrim(vec,n);
		auto i = lower_bound(vec.begin(),vec.end(),++n);
		cout << i-vec.begin() << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
const int N = 1000000;
bool prime[N];
int p[N],tot=0;
void init(){
    for(int i = 2; i < N; i ++) prime[i] = true;
    for(int i = 2; i < N; i++){
        if(prime[i]) p[tot ++] = i;
        for(int j = 0; j < tot && i * p[j] < N; j++){
            prime[i * p[j]] = false;
            if(i % p[j] == 0) break;
        }
    }
}

int main()
{
   init();
   int n;
   while(scanf("%d",&n)==1)
   {
      int sum=0;
      for(int i=0;i<tot;i++)
      {
         if(p[i]<=n)
            sum++;
         else break;
      }
      cout<<sum<<endl;
   }
   return 0;
}