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++: #include<bits/stdc++.h>
# define max 1000000
int a[max];
int a1[max];
int main()
{
    long m,n,i,j,k,l,c;
    for(i=2; i<max; i++) a[i]=1;
    k=2;
    for(i=2; i*i<=max; i++)
    {
        for(j=k+k; j<max; j=j+k) a[j]=0;
        k++;
        for(; !a[k]; k++);
    }
    a1[1]=0;
    c=1;
    for(i=2; i<max; i++)
    {
        if(a[i])
        {
            a1[i]=c;
            c++;
        }
        else a1[i]=c;
    }
    while(scanf("%ld",&n)==1)
    {
        if(n==1)
        {
            printf("0\n");
            continue;
        }
        if(a[n]) printf("%d\n",a1[n]);
        else printf("%d\n",a1[n]-1);
    }
    return 0;
}

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

int main()
{

	int n,k,p[100000];
	p[0]=2;
	while(cin>>n){
	k=0;
	for(int i=3;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				p[k]=i;
			}
		}
	}

	cout<<k+1<<endl;
	}
}

C++: //Prime Number

#include<cstdio>
using namespace std;

int Isprime[1000000];
int prime[1000000];      //?´???°?????????????????????

//??¨??????????????????????????????????´???°?????????
void a_prime(){
    int n = 1000000;
    int p = 0;
    //??????????????§???????????????
    for(int i = 0; i < n; i++) Isprime[i] = 1;
    //0??¨1????´???°??§??????
    Isprime[0] = Isprime[1] = 0;
    for(int i = 2; i < n; i++){
        if(Isprime[i]) prime[p++] = i;
        for(int j = 2*i; j < n; j += i){
            Isprime[j] = 0;
        }
    }
    
    //?´???????????????£?????????
    for(int i = 1; i < n; i++) Isprime[i] += Isprime[i-1]; 
    
}


int main(void){
    int no;
    a_prime();
    while(scanf("%d", &no) != EOF){
        printf("%d\n", Isprime[no]);
    }
    
    return 0;
}

C++: #include<iostream>
#include<math.h>
#define MAX 100000
using namespace std;
int main(){
	bool p[MAX+1];
	int n,count;
	for(int i=2; i<=MAX; i++)
		p[i] = true;
	for(int i=2; i<=sqrt(MAX); i++){
		if(p[i] == true){
			for(int j=2*i; j<=MAX; j++){
				if(j%i == 0)
					p[j] = false;
			}
		}
	}
	while(cin >> n){
		count = 0;
		for(int i=0; i<=n; i++){
			if(p[i] == true)
				count++;
		}
		cout << count << endl;
	}
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V + 1];
int sum[MAX_V + 1];
int main() {
  int i, k, v, n, max = 0;
  for(i = 2; i <= MAX_V; i++) {
    prime[i] = 1;
  }
  for(i = 2; i*i <= MAX_V; i++) {
    if(prime[i]){
      for(k = 2 * i; k <= MAX_V; k += i) {
        prime[k] = 0;
      }
    }
  }
  while(scanf("%d", &n) != EOF){
    for(i = 2;i <= n;i++){
      sum[n] += prime[i];
    }
  printf("%d\n", sum[n]);
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
    int n = 999999;
    char* p;
    int t = 2;

   

    p = new char[n];
    for(int i = 0; i < n; i++) {
        p[i] = 1;
    }
    p[0] = p[1] = 0;
    
    for(int i = 3; i < n; i++) {
        if(p[i] == 0)
            continue;
        for(int point = 2; point < n; point += i) {
            p[point] = 0;        
        }
    }
    
    while(cin >> n) {
        int c = 0;
        for(int i = 1; i <= n; i++) {
            if(p[i]) {
                c++;
            }
        }
        cout  << c << endl;
    }



    return 0;
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[100000]={0};
		int ans=0;

		for(i=0;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[m]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: /*
Volume0-0009
*/
#include <iostream>
#include <stdlib.h>
#include <string.h>

#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE
#define BUFLEN 1024

using namespace std;

int main(int argc, char *argv[]){
  int f[N];

  //  memset(f, TRUE, N);
  f[0]=FALSE;
  f[1]=FALSE;
  for (int i=2; i<N; i++)
    f[i] = TRUE;

  for (int i=2; i<N; i++){
    if (f[i] == TRUE ) {
      for (int j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }

  while (cin >> int n) != NULL){
    int m = 0;
    for (i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }
    cout << m;
  }
 
  exit(0);
}

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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

vector<int> prime;
bool is_prime[1000010];
int sieve(int n) {
  fill(is_prime + 2, is_prime + 1000010, true);
  for (int i = 2; i <= n; i++) {
    if (is_prime[i]) {
      prime.emplace_back(i);
      for (int j = 2 * i; j <= n; j += i) is_prime[j] = false;
    }
  }
  return prime.size();
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  sieve(1000000);
  int n;
  while (cin >> n) {
    cout << upper_bound(prime.begin(), prime.end(), n) - prime.begin() << endl;
  }

  return 0;
}

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

int primes[78498], primepis[1000000], num_primes;
int calculated;
int main() {
	primes[0] = 2;
	primepis[2] = 1;
	calculated = 2;
	num_primes = 1;
	for (int i = 3; i <= 999999; i += 2) {
		bool is_prime = true;
		int max = (int)(sqrt(i)) + 1;
		for (int j=1; primes[j] < max && j<num_primes; j++) {
			if (i%primes[j] == 0) {
				is_prime = false;
				break;
			}
		}
		if (is_prime) {
			primes[num_primes++] = i;
			primepis[i] = primepis[i + 1] = primepis[i - 1] + 1;
		}
		else {
			primepis[i] = primepis[i + 1] = primepis[i - 1];
		}
	}
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		printf("%d\n", primepis[n]);
	}
}

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

using namespace std;

bool isprime(int N)
{
	for (int I = 2; I <= sqrt(N); I++)
	{
		if (N % I == 0) return false;
	}

	return true;
}

int main()
{
	int n;

	int c = 0;

	cin >> n;

	for (int i = 2; i <= n; i++)
	{
		if (isprime(i) == true)
		{
			c += 1;
		}
	}

	cout << c << endl;

	return 0;
}

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

using namespace std;

vector<int> Prime;
void PrimeCalc()
{
	bool IsPrime[1000000];
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int n;
	while(cin >> n)
	{
		int ans = 0;
		int pos = 0;
		for(int i = 0; i < Prime.size(); ++i)
		{
			if(Prime[i] <= n)
			{
				++ans;
			}
			else
			{
				break;
			}
		}
		cout << ans << endl;
	}
}

int main()
{
	solve();
	return(0);
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

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