Go: package main

import (
  "fmt"
  "math"
)

func main() {
  const N = 1000000
  var temp [N+1]bool
  for i:=0; i<N+1; i++ {
    temp[i] = true
  }
  temp[0] = false
  temp[1] = false
  for i:=2; i<int(math.Ceil(math.Sqrt(float64(N+1)))); i++{
    if (temp[i]){
      for j:=i*2; j<N+1; j+=i{
        temp[j] =false
      }
    }
  }
  var a int
  var b int
  for _, err := fmt.Scan(&a); err == nil; _, err = fmt.Scan(&a) {
    b = 0
    for i:=0; i<=a; i++{
      if temp[i] {
        b++
      }
    }
    fmt.Println(b)
  }
}

C++: 

#define MAX 100

main(){
  int in_num;
  int i, put, j, k = 0, l;
  int count = 0;
  int res;
  int pres[MAX], flag = 0;

  while(1){
  res = scanf("%d", &in_num);

  if(res == EOF) break;

  for(i = 1 ; i <= in_num ; i++){
    /* iが現在まで判明している素数の倍数でないかを調べる */
    for(l = 0 ; pres[l] != NULL ; l++){
      if(i % pres[l] != 0){
        flag = 1;
      }
    }
    /* そうでなかったら以下を実行 */
    if(flag == 1){
      for(j = 2 ; j <= i ; j++){
        put = i % j;

        if(put == 0 && i != j) break;

        if(put == 0){
	  if(k < MAX){
	    /* kが最高格納数以下なら素数を保存 */
	    pres[k] = i;
	    k++;
	  }
	  printf("%d\n", i);
          count++;
          break;
        }
      }
    }
  }

  printf("%d\n", count);
  count = 0;
  }
  return 0;
}

C++: #include<stdio.h>
#include<math.h>
#define MAX_S 999999

int main(void) {
	int prime_f[MAX_S], prime_sum[MAX_S], sum = 0, n;

	for (size_t i = 0; i < MAX_S; i++)
	{
		prime_f[i] = 1;
		prime_sum[i] = 0;
	}
	prime_f[0] = 0;

	for (size_t i = 1; i < sqrt(MAX_S); i++)
	{
		if (prime_f[i] == 1) {
			for (size_t j = i + 1; j*(i + 1) <= MAX_S; j++)
			{
				prime_f[(i + 1)*j - 1] = 0;
			}
		}
	}

	for (size_t i = 0; i < MAX_S; i++)
	{
		if (prime_f[i] == 1) sum++;
		prime_sum[i + 1] = sum;
	}

	while (scanf("%d", &n) != EOF)
	{
		printf("%d\n", prime_sum[n]);
	}
	return 0;
}

C++: #include "iostream"
#include "string.h"
using namespace std;
bool visit[1000000];
int prime[1000000];

void isPrime()
{
    int j=0;
    for(int i=2;i<1000000;i++)
    {
        if(visit[i])
            prime[j++]=i;
        for(int t=0;t<j&&i*prime[t]<1000000;t++)
        {
            visit[i*prime[t]]=false;
            if(i%prime[t]==0)
                break;
        }
    }
}

int main()
{
    int N=30;
    int n;
    memset(visit,true,1000000);
    visit[0]=visit[1]=false;
    isPrime();
    while(cin>>n)
    {
        int cnt=0;
        for(int i=2;i<=n;i++)
            if(visit[i])
            cnt++;
        cout<<cnt<<endl;
    }
    return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
	int n, p, k, count;
	vector<int> num(1000000, 1);
	while(cin>>n){
		count=0;
		num[0]=0; num[1]=0;
		for(int i=4; i<=n; i+=2){
		num[i]=0;
		}
		for(int i=0; i<=n; i++){
			p = i+i+3;
			for(k=p+p; k<=n; k+=p){
				num[k]=0;
			}
		}
		for(int i=0; i<=n; i++){
			if(num[i]==1)
				count++;
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>

using namespace std;

bool isPrimes[1000000];

int main()
{
	int n;
	while (scanf("%d", &n) != EOF)
	{
		int res = 0;
		for (int i = 0; i <= n; ++i)
			isPrimes[i] = true;
		isPrimes[0] = isPrimes[1] = false;
		for (int i = 2; i <= n; ++i)
		{
			if (isPrimes[i])
			{
				for (int j = i*2; j <= n; j += i)
					isPrimes[j] = false;
				++res;
			}
		}
		printf("%d\n", res);
	}

	return 0;
}

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

#define N 1000000L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = (int) sqrt(N);
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <chrono>

using namespace std;

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    while (cin >> n) {
        if (n == 1) {
            cout << 0 << endl;
            continue;
        }
        
        vector<bool> is_prime(n + 1, true);
        is_prime[0] = false; is_prime[1] = false;
        for (int i = 2; i <= n; i++) {
            if (is_prime[i]) {
                for (int j = 2 * i; j <= n; j += i) {
                    is_prime[j] = false;
                }
            }
        }
        
        int ans = 0;
        for (int i = 0; i <= n; i++) {
            if (is_prime[i]) ans++;
        }
        cout << ans << endl;
    }
    
    return 0;
}

C++: // clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

template<typename V>
void eratosthenes(V &v) {
  v[0] = v[1] = false;
  loop(i, 2, v.size()) v[i] = true;
  for (int i = 2; i * i < v.size(); i++) {
    if (v[i]) {
      for (int j = i * 2; j < v.size(); j += i) {
        v[j] = false;
      }
    }
  }
}

void solve() {
  vi v(1000000);
  eratosthenes(v);
  loop(i, 1, v.size()) v[i] += v[i - 1];
  int n;
  while (cin >> n) cout << v[n] << endl;
}

C++: #include <cstdio>

int main(){
	int n;
	static bool c[1000000]={true};
	static int t[1000000];t[0] = 0;
	for(int i = 2;i < 1000000;i++){
		for(int j = 2;i*j < 1000000;j++){
			c[i*j-1] = true;
		}
	}
	for(int i = 1;i < 1000000;i++){
		if(c[i])t[i]=t[i-1];
		else t[i] = t[i-1]+1;
	}
	while(scanf("%d", &n)){
		printf("%d\n", t[n-1]);
	}
	return 0;
}

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

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