Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

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

using namespace std;


int main(){

	int i, j, k;
	int n;

	while(cin >> n){

		int count = 0;

		if(n>2){
			count ++;
			for(i=3 ; i<=n ; i+=2){
				for(j=3 ; j<=(int)sqrt(i) ; j+=2){
					k = i % j;
					if(k == 0) break;
				}
				if(j > (int)sqrt(i)) count ++;
			}
		}
		cout << count << endl;

	}


	return 0;
}

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

int main() {
	vector<bool>hantei(1000000, true);
	vector<int>sosuu(1000000);
	int s = 0;
	for (int a = 2; a < 1000000; a++) {
		if (hantei[a]) {
			s++;
			for (int b = a * 2; b < 1000000; b += a)hantei[b] = false;
		}
		sosuu[a] = s;
	}
	int c;
	while (cin >> c, c) {
		cout << sosuu[c] << endl;
	}
}

C++: #include<iostream>

int main(){

	bool data[100001];

	for (int i = 0; i < 100001; i++)
		data[i] = true;

	int in;

	int res=0;

	for(int i=2;i<=100000;i++){
		for (int j = 2; j < i; j++) {
			if (i%j == 0){
				data[i] = false;
				goto fl;
		}
	}
	fl:;
	}

	while (true) {

		std::cin >> in;

		for (int i = 2; i <= in; i++) {
			if (data[i] == true)
				res++;
		}

		std::cout << res << std::endl;

	}

		return 0;
}

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

const static double	de_PI	= 3.14159265358979323846;
const static int	de_MOD	= 1000000007;
const static int	de_MAX	= 999999999;
const static int	de_MIN = -999999999;

inline int Sieve_of_Eratothenes(const int n) {

	std::vector<bool> flg(n + 1, true);
	for (int i = 2; i < n; i++) {
		if (flg[i]) {
			for (int j = i + i; j <= n; j += i) {
				flg[j] = false;
			}
		}
	}

	return(std::count(flg.begin(), flg.end(), true) - 2);

}

int main(void) {

	//std::ifstream in("123.txt");	std::cin.rdbuf(in.rdbuf());

	int a = 0;
	std::vector<int> A;
	while (std::cin >> a) {
		A.push_back(a);
	}

	std::for_each(A.begin(), A.end(),
		[](int i) {std::cout << Sieve_of_Eratothenes(i) << std::endl; });
}

C++: #include<stdio.h>
#include<math.h>
int judge(int x)
{
	for (int i = 3; i < sqrt(x) + 1; i++)
		if (x%i == 0)
			return 0;
	return 1;
}
int main()
{
	int a, num;
	while (scanf("%d", &a) != EOF)
	{
		num = 1;
		if (a < 2)
			num = 0;
		for (int i = 3; i <= a; i+=2)
			if (judge(i))
				num++;
		printf("%d\n", num);
	}
	return 0;
}

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

void AOJ0009()
{
	int n = 0;
	int prime[100000];
	int count = 0;
	for (int i = 2; i <= 100000; i++)
	{
		int j = 2;
		bool flag = false;
		for (j = 2; j <= i; j++)
		{
			if (i % j == 0)
				break;
		}
		if (i == j)
		{
			prime[count] = i;
			count++;
		}
	}

	while (cin >> n)
	{
		count = 0;
		while (prime[count] <= n)
		{
			count++;
		}
		cout << count << endl;
	}
}
int main()
{
	//AOJ0005();
	//AOJ0007();
	AOJ0009();
	return 0;
}

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

using namespace std;

int isprime(int x){
	int i;
	if(x == 2 || x == 3) return 1;
	else if(x % 2 == 0) return 0;
	else{
		for(i = 3; i <= sqrt(x); i += 2){
			if(x % i == 0) return 0;
		}
		return 1;
	}
}

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

C++: #include<iostream>
#include<cmath>
#define FOR(x,s,g) for(int x=(s);x<=(g);x++)
using namespace std;

int main(){
  int n;
  while(cin>>n){
    int count=0;
    FOR(i,2,n){
      int e=sqrt(i);
      FOR(j,2,e){
	if(i%j==0){
	  goto end;
	}
      }
      count++; 
    end:
      ;
    }
    cout<<count<<endl;
  }
  return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <cstring>
#include <climits>
#include <cmath>
#include <cfloat>

#define FOR(i,b,n) for(int i=b;i<n;i++)
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define INF 1<<25
#define LIM 1000000

using namespace std;

int n,sum,out;
bool prm[1000000];

void eucprime()
{
	FOR(i, 2, LIM)
	{
		if(prm[i] == 0)
		{
			for( int j = 2; j*i < LIM; j++)
			{
				prm[i*j] = 1;
			}
		}
	}
}
	

int main()
{
	while( cin >> n, !cin.eof())
	{
		CLR(prm);
		prm[0] = 1; prm[1] = 1;
		eucprime();
		
		int cnt=0;
		
		FOR(i, 0, n+1)
		{
			if(prm[i] == 0)
				cnt++;
		}
		
		cout << cnt << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V + 1];
int sum[MAX_V + 1] = {0};
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;
      }
    }
    sum[i] = prime[i - 1] + sum[i - 1];
  }
  while(scanf("%d", &n) != EOF){
    printf("%d\n", sum[i + 1]);
  }
  return 0;
}

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


using namespace std;
#define MAX_NUM 999999


int do_count(bool *isPrime, int n);

int main(){
  int n;
  bool flag = false;
  int numPrime[MAX_NUM];
  int pivot = 1;
  
  for(int i=0;i<MAX_NUM;i++){
    numPrime[i] = 0;
  }
  
  while(cin >> n){
    int cnt=0;
    if(n < pivot){
      //      cout << "n < pivot" << endl;
      cnt = numPrime[n];
      cout << cnt << endl;
      continue;
      
    }
    
    if(n >= pivot){
      //      cout << "n >= pivot" << endl;
    // i???????????????
    }
    
    for(int i=pivot+1;i<=n;i++){
      flag = false;
      //?´???°?????????????????§??????
      for(int j=2;j<=sqrt(i);j++){
	if(i%j==0){
	  flag = true;
	  break;
	}
      }
      if(flag){
	numPrime[i] = numPrime[i-1];
	continue;
      }else{
	numPrime[i] = numPrime[i-1] + 1;
      }
    }
    cnt = numPrime[n];
    cout << cnt << endl;
  }
}

int do_count(bool *isPrime, int n){
  int cnt=0;
  for(int i=0;i<=n;i++){
    if(isPrime[i]==true){
      cnt++;
    }
  }
  return cnt;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int a[MAX_V] = {'0'};
int sum[MAX_V+1];
int main() {
  int i, k, v, j, m, n;
  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;
      }
    }
  }
  sum[0] = 0;
  for(m = 0; m < MAX_V; m++) {
    sum[m+1] = sum[m] + prime[m];
  }
  while( scanf( "%d", &n ) != EOF ) {
    printf( "%d\n", sum[n+1] );
  }
  return 0;
}

C++: #include<stdio.h>

int main(){
	
	static int prime[999999 + 1];
	
	int i, j, k = 0, limit;
	
	for(i = 2; i < 1000000; i++){
		prime[i] = 1;
	}
	
	prime[0] = prime[1] = 0;
	
	for (i = 2; i < 1000000; i++){
		if(prime[i]){
			for (j = i + i; i < 1000000; j += i){
				prime[j] = 0;
			}
		}
	}
	while(scanf("%d", &limit) != EOF){
		for(i = 2; i <= limit; i++){
		
			if(prime[i]){
				k++;
			}
		}
	
		printf("%d\n", k);
	
	}
	return 0;
	
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main()
{
	int n,sum,i,k,sqrtm;
	while(cin>>n)
	{
		sum=3;
		if(n<2){cout<<0<<endl;continue;}
		if(n==2){cout<<1<<endl;continue;}
		if(n==3){cout<<2<<endl;continue;}
		if(n==5 || n==4){cout<<3<<endl;continue;}
		 i=6;
	 while(i<n)
		{
			i++;
			if(i%2==0)continue;
			if(i%3==0)continue;
			if(i%5==0)continue;
			sqrtm=sqrt(i);
			for(k=2;k<=sqrtm+1;k++)
			{if(i%k==0)break;}
			if(k==sqrtm+2)sum++;
		}
		cout<<sum<<endl;
	}
}

C++: #include <cstdio>
int d[1000000],c[1000000];
int main() {
	int i,j,r=0,n;
	for(i=2;i<500000;i++) {
		if(d[i]){c[i]=r;continue;}
		c[i]=++r;
		for(j=i*2;j<=999999;j+=i)d[j]=1;
	}
	while(scanf("%d",&n)!=EOF) {
		printf("%d\n",d[n]);
	}
}