Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	int time;
	vector<int> v;
	v.push_back(2);
	while(cin>>time){
		int abcd=0;
		if(time>v[v.size()-1]){
			for(int abc=1+v[v.size()-1];abc<=time;abc++){
				for(int bcd=0;bcd<(int)v.size() ;bcd++){
					if(abc%v[bcd]==0){
						goto end;
					}
				}
				v.push_back(abc);
				end:;
			}
		}
		for(int abc=0;v[abc]<=time;abc++){
			abcd++;
		}
		cout<<abcd<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <numeric>
#define MAX 1000000
using namespace std;

bool isPrime(int x) {
  if(x == 2) {
	return true;
  }
  
  if(x < 2 || x % 2 == 0) {
	return false;
  }
  for(int i = 3; i <= sqrt(x); i += 2) {
	if(x % i == 0) {
	  return false;
	}
  }
  return true;
}

int main() {
  int n;
  bool a[MAX] = {};

  for(int i = 1; i < MAX; ++i) {
	if(isPrime(i)) {
	  a[i] = true;
	}
  }
  /*
  for(int i = 1; i < MAX; ++i) {
	if(isPrime(i)) {
	  cout << i << " ";
	}
  }
  */
  while(cin >> n) {
	cout << accumulate(&a[1], &a[n + 1], 0) << endl;
  }
  return 0;
}

/*-- primitive algorithm --*/
/*
bool isPrime(int n) {
  for(int i = 2; i < n; ++i) {
	if(n % i == 0) return false;
  }
  return true;
}
*/

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

bool a[1000001] ;
int main(){
    a[0] = 1 ;
    a[1] = 1 ;
    vector<int> v ;
    for(int i=2;i<=1000000;i++){
        if ( a[i] == 0 ){
            v.push_back(i);
            for(int j=i+i;j<=1000000;j+=i){
                a[j] = 1 ;
            }
        }
    }

    int x ;
    while(cin >> x){
        long long c = 0 ;
        for(int i=0;i<v.size();i++){
            if ( v[i] > x ) break;
            c++;
        }
        cout << c << endl;
    }



    return 0 ;
}

C++: #include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;

constexpr int LIM = 1000000;

static char isprime[LIM];
static int numofprime[LIM];

void setprime(int N) {
    fill(isprime, isprime + N + 1, 1);
    isprime[0] = isprime[1] = 0;
    for(int x = 2, lim = (int)sqrt(N); x <= lim; ++x) {
        if(isprime[x]) {
            for(int y = x * x; y <= N; y += x) {
                isprime[y] = 0;
            }
        }
    }
    numofprime[0] = 0;
    for(int x = 0; x < N; ++x) {
        numofprime[x + 1] = numofprime[x] + isprime[x + 1];
    }
}

int main() {
    setprime(999999);
    int n;
    while(scanf("%d", &n) != EOF) {
        printf("%d\n", numofprime[n]);
    }
    return 0;
}

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

using namespace std;

int prime[10000];
bool is_prime[1000000];

int sosuu(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=i*2; j<=n; j+=i) {
                is_prime[j]=false;
            }
        }
    }
    return p;
}

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

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

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		if (n / 1000000 > 0) {
			int count = 0;
			for (int a = 2; a <= n; a++) {
				if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) 
					count++;
				if (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;

bool isprime_ge3(int n) {
	if (!(n&1))
		return false;
	int lim = (int)sqrt((double)n);
	for (int i = 3; i <= lim; i+=2)
		if (!(n%i))
			return false;
	return true;
}

int main(void) {
	int n;
	while (cin >> n) {
		if (n < 2)
			cout << 0 << endl;
		else if (n == 2)
			cout << 1 << endl;
		else {
			int total = 1;
			for (int i = 3; i <= n; i++) {
				if (isprime_ge3(i))
					total++;
			}
			cout << total << endl;
		}
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <math.h>
#define REP(i,n) for(int (i) = 0; i <= n; ++i)
#define N 1000000
using namespace std;

vector<int>prime;

void Eratosthenes(){
    bool f[N];
    for(int i = 0; i < N; i++){
        f[i] = true;
    }
    f[0]=f[1]=false;
    
    for(int i = 2; i < sqrt(N); i++){
        if(f[i]){
            for(int j = 0; i * (j + 2) < N; j++){
                f[i *(j + 2)] = false;
            }
        }
    }
    
    for(int i = 2; i < N; i++){
        if(f[i]){
            prime.push_back(i);
        }
    }
}

int main() {
    int n;
    Eratosthenes();
    while(cin>>n){
        int ret = 0;
        for (int j = 0; j < prime.size(); j++) {
            if (prime[j] > n)break;
            ret++;
        }
        cout<<ret<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <ctime>
#define pb(x) push_back(x)
#define me(x,y) memset(x,y,sizeof(x))
#define sd(x) scanf("%d",&x)
#define ss(x) scanf("%s",x)
#define sf(x) scanf("%f",&x)
#define slf(x) scanf("%lf",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define pc(x) printf("%c",x)
#define pn() printf("\n")
#define plld(x) printf("%lld\n",x)
#define ps(x) printf("%s\n",x)
#define max(x,y) (x>=y?x:y)
#define min(x,y) (x<y?x:y)
#define sum(x,y) (x+y)
#define INF 0x3f3f3f3f

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

const int maxn=999999+5;

bool vis[maxn];
int prime[maxn];
int sum[maxn];

int get_prime() {
    me(vis,true);
    vis[0]=vis[1]=true;
    int cnt=1;
    for(int i=2;i<maxn;i++) {
        if(vis[i]) prime[cnt++]=i;

        for(int j=1;j<cnt && i*prime[j]<maxn;j++) {
            vis[i*prime[j]]=false;
            if(i%prime[j]==0) break;
        }
    }
    return cnt;
}

void solve() {
    int cnt=get_prime();
    me(sum,0);
    prime[0]=0;
    for(int i=1;i<cnt;i++) {
        for(int j=prime[i];j<prime[i+1];j++) sum[j]=i;
    }
}


int main() {
    solve();
    int n;
    while(sd(n)!=EOF) pd(sum[n]);
	return 0;
}

C++: #include <stdio.h>

int main(){
	int sosuu[] = { 2, 3, 5 }, i, x, y = 3,n,z;
	
	while (scanf("%d", &n)!=EOF){
		z = 0; 
		for (i = 3; i < n + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++;}
			}
		}
		for (i = 0; i < y; i++){ if (sosuu[i] > n)break; z++; }
		printf("%d\n", z);
	}
	return 0;
}

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

int main(){

    while(true){
	int n;
	cin >> n;
	if(cin.eof()) break;

	int res = 0;
	bool flg = true;
	for(int i=2;i<=n;i++){
	    flg = true;
	    for(int j=2;j*j<=i;j++){
		if(i % j == 0) flg = false;
	    }
	    if (flg) res++;
	}
	cout << res << endl;
    }

    return 0;
}

C++: #include <iostream>

using namespace std;

void solve(int n) {
	int prime[n];
	int j=0;
	for (int i=2; i<=n; i++) {
		prime[j] = i;
		j++;
	}
	int p;
	for (int i=0; i<n; i++) {
		p = prime[i];
		if (p == -1) continue;
		for (int k=i+1; k<n; k++) {
			if (prime[k]%p == 0)
				prime[k] = -1;
		}
	}
	int count = 0;
	for (int i=0; i<n; i++)
		if (prime[i] != -1) count++;
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		if (n<=1) cout << 0 << endl;
		solve(n);
	}
	return 0;
}