Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

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

int main(){
	int n;
	int *prime,i,j;
	int count;
	bool flag;
	//for(i=1;i<1000000;i++)n[i]=1;

	while((cin >> n)!= NULL){
		count = 0;
		prime = new int[(int)sqrt(n)+1];
		for(i = 3; i <= n; i+=2){
			flag = true;
			for(j = 0; j < count; j++){
				if(i % prime[j] == 0){
					flag = false;
					break;
				}
			}
			if(flag == true){
				prime[count++] = i;
			}
		}
		if(n > 1)	count++; //2

		cout << count << endl;

		delete prime;
	}
//	while(1);
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int i,j,n;
	bool prime[1000001];
	for (i = 3; i <= 1000000; i += 2){
		prime[i] = true;
	}
	prime[2] = true;

	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = false;
			}
		}
	}
	while(cin >> n && n){
		int count = 0;
		for(i=2;i<=n;i++){
			if(prime[i] == true) count++;
		}
		cout << count << endl;
	}

	return 0;
}

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

int main()
{
	unsigned int  n,j;
	cin >> n;
	unsigned  int num[n],count = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> num[i];
	}
	for(int i = 0; i < n; i++)
	{
		for(j = 2; j < num[i]; j++)
		{
			if((num[i] % j) == 0)
			{
				break;
			}
		}
		if(j == num[i]) count++;
        }
	cout << count << endl;
	return 0;
}

C++: #include<iostream>
using namespace std;
bool pd(int x)
{
	int i,j;
	int flag=1;
	for(i=2;i<x;i++)
	{
		if(x%i==0)
		{
			flag=0;
		}
	}
	if(flag)
	return true;
	else return false;
}
int main()
{
	int n;
	while((scanf("%d",&n))!=EOF)
	{
		int i,j,k;
		k=0;
		for(i=2;i<=n;i++)
		{
			if(pd(i))
			{
				k++;
			}
		}
		printf("%d\n",k);
	}
	return 0;
}

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

int main()
{
	int n, i, j, count;

	while(scanf("%d", &n) != EOF){
		count = n - 1;

		for (i = 2; i <= n; i++){
			for (j = 2; j < i; j++){
				if(i%j == 0) {count--; break;}
			}
		}

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

	return 0;
}

C++: #include<stdio.h>
#include<math.h>
int gurobal[1000001]={0};
int main(void)
{
	int n=0;
	int i=0,j=0;
	int heihoukon=0;
	int count=0;
	while(scanf("%d",&n)!=EOF)
	{
		count=0;
		gurobal[1]=0;
		for (i=2;i<=n;i++)
		{
			gurobal[i]=1;
		}
		(int)heihoukon=sqrt((double)n);
		for (i=2;i<=heihoukon;i++)
		{
			if (gurobal[i]!=0)
			{
				for (j=i*2;j<=n;j+=i)
				{
					gurobal[j]=0;
				}
			}
		}
		for (i=2;i<=n;i++)
		{
			if (gurobal[i]!=0)
			{
				count++;
			}
		}
		printf("%d\n",count);
	}
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main() {
	int n, count = 0;
	double l, m;
	while(cin >> n) {
		for(int i = 2; i <= n; i++) {
			count++;
			int j;
			l = sqrt(i * 1.0);
			m = l;
			for(j = 2; j <= m; j++) {
				if(i % j == 0) {
					count--;
					break;
				}
			}
		}
		cout << count << endl;
		count = 0;
	}

	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
 
 
// cin >>
// cin <<
bool isPrime(int x){
    if(x==2) return true;
    if(x<2||x%2==0) return false;
    int i=3;
    while(i<=sqrt(x*1.0)){
         if (x%i==0)return false;
        i= i+2;
    }
    return true;
}
int main(){
    int in[30]={};
    int out=0;
	int max=0;
	bool flag[1000002];
    for(int i=0;i<30;i++){
		cin >>in[i];
		if(i==0){
			max=in[i];
		}else{
			if(in[i]>max){
				max=in[i];
			}
		}
	}
	for(int j=0;j<max+1;j++){
		if(isPrime(j)==true){
			flag[j]=true;
		}else{
			flag[j]=false;
		}
    }
	
    for(int i=0;i<30;i++){
		out=0;
		for(int j=0;j<in[i];j++){
			 if(flag[j]==true){  
				 out++;
			 }
		}
       cout <<out <<endl;
    }
     
    return 0;
}

C++: #include<stdio.h>
#include<math.h>
int main()
{
    long long n,i,j;
    int c=0;
    scanf("%lld",&n);

    for(i=2;i<=n;i++)
    {
        for(j=2;j<i;j++)
        {
            if(i%j==0) break;
        }
        if(j==i) c++;
    }
    printf("%d\n",c);
}

C++: #define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int pn = 0;
int p[1000000];
int s[1000000];

int main() {
    s[1] = 0;
    int i = 2;
    do {
        bool flg = true;
        for(int j = 0; j < pn; j++) {
            if(p[j] * p[j] > i) break;
            if(i % p[j] == 0) {
                flg = false;
                break;
            }
        }
        if(flg) p[pn++] = i;
        s[i] = pn;
    } while((++i) <= 999999);


    int n;
    while(cin >> n) {
        cout << s[n] << endl;
    }
    return 0;
}

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++: ///
// File:  0009.cpp
// Author: ymiyamoto
//
// Created on Wed Nov  8 23:17:22 2017
//

#include <cmath>
#include <cstdint>
#include <iostream>

using namespace std;

static int32_t primes[1000000];

bool is_prime(uint32_t val)
{
  if (primes[val] == 1) return true;
  if (primes[val] == -1) return false;

  for (uint32_t i = 2; i <= sqrt(val); i++) {
    if (val % i == 0) {
      primes[val] = -1;
      return false;
    }
  }

  primes[val] = 1;
  return true;
}

int32_t main()
{
  while (true) {
    uint64_t n;
    cin >> n;
    if (cin.eof()) break;

    uint32_t count = 0;
    for (uint32_t i = 2; i <= n; i++) {
      if (is_prime(i)) count++;
    }
    cout << count << endl;
  }

  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 = 1000;
  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 = (long int) 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] == true) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

C++: #include <iostream>

int func(int n){
	int i, count = 0;

	while (1 < n){
		for (i = 2; i < n; i++){
			if (n%i == 0){
				break;
			}
		}
		if (i == n){
			count++;
		}
		n--;
	}
	return count;
}


int main(){
	int input;

	while (std::cin >> input){
		std::cout << func(input) << "\n";
	}

	return 0;
}