Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int prime(int a)
{
	if(a<=2)
	return 1;
	
	if(a%2==0)
	return 0;
	
	for(int i=3 ; (i*i)<=a ; i+=2)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		int d=0;
		forin(i,2,a+1)
		{
			if(prime(i)==1)
			d++;
		}
		printf("%d\n",d);
	}
	return 0;
}

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

int main()
{int c,g;
	bool prime[30] ;
	for(int i = 0 ; i <=30 ; i++ )
	prime[i] = true ;
	prime[0] = prime[1] = false ;
	for(int i = 2 ; i <=30 ; i++){
		if(prime[i]){
					for(int j = i * i ; j <=30 ; j += i )
					prime[j] = false ;
		}
	}


while(cin>>g){
	c=0;

	for(int i = 0 ; i <= g ; i++){
		if(prime[i])
		c++;
	}
cout<<c<<endl;
}
}

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

int main(){
	bool arr[1000003];
	int n;
	while(cin >> n){
		int count = 0;
		for(int i = 2; i < 1000003; i++) arr[i] = true;

		for(int i = 2; i < sqrt(n); i++){
			if(arr[i] == true) {
				for(int j = 0; i * (j + 2) <= n; j++) {
				arr[i * (j + 2)] = false;
				}
			}
		}
		for(int i = 2; i <= n; i++){
			if(arr[i] == true) count++;
		}

		cout << count << "\n";
	}
}

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

using namespace std;

vector<int> a(1000000, 1);

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

	int n;
	while (scanf("%d", &n) != EOF) {
		cout << a[n] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <cmath>
std::vector<int> PRIMES;

void init_primes(int max)
{
  if (max < 2) return;
  std::set<int> candidate;
  PRIMES.push_back(2);
  for (int i = 3; i < max; i+=2) {
    candidate.insert(i);
  }
  for (int i = 3; i < sqrt(max); i+=2) {
    auto it = candidate.find(i);
    if (it != candidate.end()) {
      PRIMES.push_back(i);
      int del_num = i;
      while (del_num < max) {
        it = candidate.find(del_num);
        if (it != candidate.end()) candidate.erase(it);
        del_num += i;
      }
    }
  }
  for (auto it = candidate.begin(); it != candidate.end(); ++it) {
    PRIMES.push_back(*it);
  }
}

int main()
{
  const int max = 1000000;
  init_primes(max);
  int i;
  while (std::cin >> i) {
    auto it = PRIMES.begin();
    int n = 0;
    while (*it <= i && it != PRIMES.end()) {
      n++;
      it++;
    }
    std::cout << n << std::endl;
  }
  return 0;
}

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

int main(){

	int n,count;
	while(cin>>n){
		count=0;
		for(int i=2; i<=n; i++){
			int num = 0;
			for(int j=1; j<=i ;j++){
				if(i%j==0) num++;
			}
			if(num==2){
				count++;
			}
		}
		cout << count << endl;
	}
    return 0;
}

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

bool dec(int i, int prime[]) {
  for (int j = 0; prime[j] != 0; j++) {
    if (i % prime[j] == 0) {return false;}
  }
  return true;
}

int main() {
  int n;
  while (cin >> n) {
    int count = 0;
    int prime[1000000];
    for (int i = 0; i < 1000000; i++) {
      prime[i]=0;
    }
    if (n >= 2) {
      prime[0] = 2;
      count++;
    }
    for (int i = 3; i <= n; i += 2) {
      if (dec(i, prime)) {
	prime[count] = i;
	count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

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

signed main(){
  int p[100006];
  loop(i,2,100001){
    if(Is_Prime(i))p[i]=1;
  }
  rep(i,100001)p[i+1]+=p[i];
  int n;
  while(cin>>n){
    cout<<p[n]<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int N, i, j, H[1000001];
bool A[1000001];
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(A,true,1000000*sizeof(bool));
	A[1]=false;
	for (i=2;i<1000;i++) {
		if (A[i]) {
			for (j=i;j*i<1000000;j++) {
				A[i*j]=false;
			}
		}
	}
	H[1]=0;
	for (i=2;i<1000000;i++) {
		H[i]=H[i-1]+A[i];
	}
	while (cin>>N) {
		cout<<H[N]<<endl;
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X)
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto x:v)cerr<<x<<' ';cerr<<endl;
#define INF 1000000007
#define LINF 1000000000000000007
#define EPS 1e-9
typedef long long ll;

vector<long long> primelist(long long n){
  vector<bool> prime(n+1,1);
  for(long long i = 2;i <= n;i++){
    if(prime[i]){
      for(long long j = 2*i;j <= n;j += i){
        prime[j] = 0;
      }
    }
  }
  prime[0] = 0;
  prime[1] = 0;
  vector<long long> primelist;
  for(long long i = 0;i <= n;i++)if(prime[i])primelist.pb(i);
  return primelist;
}

signed main(){
  int n;
  while(cin >> n){
    cout << primelist(n).size() << endl;
  }
}