Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	a, _ := strconv.Atoi(scanner.Text())
	return a
}

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

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include <bits/stdc++.h>

using namespace std;
using ull = unsigned long long;
using ll = long long;
using lli = long long int;
using ld = long double;
using pa = pair<int,int>;
using ppa = pair<pa,int>;
#define SORT(v, n) sort(v, v+n);
#define ALL(v) v.begin(),v.end()
#define VSORT(v) sort(ALL(v))
#define GRESORT(v) sort(ALL(v),greater<ll>())
#define REVERSE(v) reverse(ALL(v))
#define overlap(v) v.erase(unique(ALL(v)),v.end())
#define debug(x) cout << #x << ": " << x << endl
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i = (b-1); i >= a; i--)
#define rrep(i,n) RFOR(i,0,n)
#define INF INT_MAX
#define SUP INT_MIN
#define mins(a,b) a = min(a,b)
#define maxs(a,b) a = max(a,b)

//4??????
//int dy[]={0, 1, 0, -1};
//int dx[]={1, 0, -1, 0};

//8??????
//int dy[]={0,0,1,-1,1,1,-1,-1};
//int dx[]={1,-1,0,0,1,-1,1,-1};

const ll MOD = 1000000007;

ll pow_mod(ll a,ll b,ll mod){
    ll tmp = 1;
    a %= mod;
    if(b > 0){
        tmp = pow_mod(a, b/2, mod);
        if(b % 2) tmp = (((tmp*tmp)%mod)*a)%mod;
        else tmp = (tmp*tmp)%mod;
    }
    return tmp;
}

int mm = 999999+1;
vector<bool> d(mm,true);

void hoge(){
    FOR(i,2,sqrt(mm)){
        for(int j = 2; i*j <= mm; j++){
            d[i*j] = false;
        }
    }
}

void solve() {
    vector<int> dp(mm,INF);
    int val;
    int m = 2;
    dp[m] = 1;
    d[0] = d[1] = false; dp[0] = dp[1] = 0;
    hoge();
    while(cin >> val){
        if(dp[val] == INF){
            FOR(i,m+1,val+1){
                dp[i] = dp[i-1] + (d[i] ? 1 : 0);
            }
            m = val;
        }
        cout << dp[val] << endl;
    }
}

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

    solve();

    return 0;
}

C++: #include <stdio.h>
#include <math.h>
int b[999999];

int prime(int x) {
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) {
			return 0;
		}
	}
	return 1;
}
int main(){
	int n;
	b[0] = 0;
	b[1] = 0;
	b[2] = 1;
	int count = 1;
	for (int i = 3; i <= 999999; i++) {
		if (prime(i))count++;
		b[i] = count;
	}
	while (scanf("%d", &n) != EOF){
		printf("%d\n", b[n]);
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
int prime(int x)
{
    int i,j=1;
    int l;
    l=sqrt(x);
    for(i=2;i<=l+1;i++)
    {
        if(x%i==0)
        {
            j=0;
            break;

        }
    }
    //if(j==0)return 0;
    if(x==2||j==1) return 1;


}
using namespace std;
int main()
{
    int n;//=999999;
    //cout<<n<<endl;
    int j,i;int s=0;
    while(cin>>n)
    {
       s=0;

        for(i=2;i<=n;i++)
        {
            if(prime(i)==1){s++;}//cout<<i<<endl;}
        }
        cout<<s<<endl;

    }



    return 0;
}

C++: #include<stdio.h>
int a[1000000];
int main(void)
{
	int s,d,f,g,h,i,j;
	a[1]=0;
	for(i=2;i<=999999;i++){
		a[i]=1;
	}
	for(i=2;i*i<=1000000;i++){
		if(a[i]!=0){
			s=2;
			while(i*s<=999999){
				a[i*s]=0;
				s++;
			}
		}
	}
/*	for(i=1;i<=100000;i++){
		if(a[i]==1){
			printf("%d\n",i);
		}
	}*/
	while(scanf("%d",&f)!=EOF){
		g=0;
		for(i=1;i<=f;i++){
		if(a[i]==1){
			g++;
		}
	}
	printf("%d\n",g);
	}
	return 0;
}

C++: #include<stdio.h>
#include<float.h>
#include<vector>


vector<int> primes;
int ref_max=2;

int makePrimenumbers(int a){
	if(a<ref_max)return 0;

	temp = ref_max;
	ref_max=a;
	int i,k,isp=1;

	for(k=temp;k<ref_max;k++){
		for(i=0;i<primes.size();i++){
			if(k%primes[i]==0){
				isp=0;
				break;
			}
		}
		if(isp==1){
			primes.push_back(k);
		}
		isp=1;
	}
	return 0;
}

int countprime(int a){
	int i;
	for(i=0;i<prime.size();i++)
		if(a<prime[i])
			break;
	return (i);
}

int main(void)
{
	int result;
	while(scanf("%d",&a)!=EOF){
		makePrimenumbers(a);
		result = countprime(a);
		printf("%d\n",result);
	}
  return 0;
}

C++: #include <iostream>
#include <string>
#include <map>
#include <vector>
#include <set>
#include <iomanip>
#include <fstream>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <utility>
#include <numeric>
using namespace std;

#define REP(i,f,n) for(int i=(f); i < (n); ++i)
#define PER(i,f,n) for(int i=(n-1); i >= f; --i)

//----------------------------------
//----------------------------------

constexpr int64_t CALCNUM = 2000000;

bool primes[CALCNUM];

signed main()
{
	for(int i = 0; i < CALCNUM; i++)
		primes[i] = true;
    ios::sync_with_stdio(false);
	vector<int> prime;

	for(int i = 2; i <CALCNUM ; i++)
	{
		if(primes[i])
		{
			prime.push_back(i);
			for(int j = 2 * i; j < CALCNUM; j += i)
				primes[j] = false;
		}
	}
	int n;
	while(cin >> n)
	{
		for(int i = 0; i < prime.size(); ++i)
			if(prime[i] > n){
				cout << i <<'\n'; break;
			}
	}
}

C++: #include <stdio.h>

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

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 10000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	
	for (int i = 2; i <= MAX; i++){
		if (!vis[i]){

			prime[i] = 1;
			for (int j = i + i; j <= MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;

			}
		}
	}
	int sum = 0;
	for (int i = 2; i <= MAX; i++){
			if (prime[i]){
				sum++;
			}
			amount[i] = sum;
		}

	int n;
	cin >> n;
		cout << amount[n]<< endl;
	return 0;
}

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

int main()
{
	int n;

	while(std::cin >> n)
	{
		std::vector<int> Sosuu(1);

		Sosuu[0] = 2;

		for( int i=2; i<n; ++i )
		{
			size_t j=0;

			for( ; j<Sosuu.size(); ++j )
			{
				if(i%Sosuu[j]==0)
				{
					break;
				}
			}
			if(j==Sosuu.size())
			{
				Sosuu.push_back(i);
			}
		}

		std::cout << Sosuu.size() << '\n';
	}
}

C++: #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 999999L
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++;
    }
    printf("%ld\n", count);
    if(c == EOF) break;
  }
  return 0;
}

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

int check[1000000 + 5];

void sieve()
{
check[1] = 1;
for(int i = 4; i <= 1000000; i += 2)
check[i] = 1;
for(int i = 3; i <= 1000; i += 2)
for(int j = i * i; j <= 1000000; j += i + i)
check[j] = 1;
for(int i = 1; i <= 1000000; i++)
check[i] += check[i - 1];
}

int main()
{
sieve();
int n;
while(cin >> n)
cout << n - check[n] << endl;
return 0;
}