Go: package main

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

func main() {
    var limit = 1000000
    var root = 1000
    var isPrime [1000000]bool
    for i := 0; i < limit; i++ {
        isPrime[i] = true
    }
    isPrime[0] = false
    isPrime[1] = false
    for i := 2; i <= root; i++ {
        if isPrime[i] {
            for j := i * i;j < limit; j+=i {
                isPrime[j] = false
            }
        }
    }
    var primeCnt [1000000]int
    var cnt = 0
    for i := 0; i < limit; i++ {
        if isPrime[i] {
            cnt++
        }
        primeCnt[i] = cnt
    }

    var sc = bufio.NewScanner(os.Stdin)
    for sc.Scan() {
        n, _ := strconv.Atoi(sc.Text())
        fmt.Println(primeCnt[n])
    }
}

C++: #include<iostream>
using namespace std;
int PrimeNum(int n){
  for(int i = 2;i <= n;i++){
    if(i == n){
      return 1;
    }
    if(n % i == 0){
      return 0;
    }
  }
}
int main(){
  int n,num;
   while(cin >> n){
    num = 0;
     for(int k = 2;k <= n;k++){
       if(PrimeNum(k) == 1){
	 num = num +1;
       } 
     }
     cout << num << endl;
     }
}

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

int main() {
	vector<int> p;
	int n;
	p.push_back(2);
	for(int i=3;i<999999;i++){
		for(int j=0;;j++){
			if(i%p[j]==0)
			break;
			if(i<p[j]*p[j]){
			p.push_back(i);
			break;
			}
		}
	}
	p.push_back(9999999);
	while(cin >> n){
		int i=0;
		while(n>=p[i]){
			i++;
		}
		cout << i << endl;
	}
	return 0;
}

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

bool isPrime(int n){
	double sqrtN = sqrt(n);
	for(int i = 3; i <= sqrtN; i += 2){
		if(!(n%i))
			return false;
	}
	return true;
}
 
int main(){
  bool prime[999999] = {};
  prime[1] = true;
  for(int i = 3; i < 999999; i += 2){
  	if(isPrime(i))
  		prime[i-1] = true;
  }
  int n;
  while(cin >> n){
  	int count = 0;
  	if(n >= 2)
  		count++;
    for(int i = 3; i <= n; i += 2){
    	if(prime[i-1])
    		count++;
    }
    cout << count << endl;
  }
}

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

typedef unsigned int Int;

Int sqrt_prm(const Int& target, Int x = 0) {
	while (x*x < target) {
		x++;
	}
	return x;
}

int main() {
	while (not std::cin.eof()) {
		Int target;
		std::cin >> target;

		std::vector<Int> primes = {};
		Int sqrt = 1;
		for (Int n = 3; n <= target; n+=2) {
			bool flag = true;

			sqrt = sqrt_prm(n, sqrt);
			for (auto&& div : primes) {
				if (div < sqrt) { break; }
				if (n % div == 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				primes.push_back(n);
			}
		}

		std::cout << primes.size() + (target >= 2 ? 1 : 0) << std::endl;
	}
}

C++: #include <iostream>
#include <cmath>
#define MAX 100001
using namespace std;

int p[MAX];

int main(){
	int counter = 0;
	p[1] = 0;
	for (int i = 2; i < MAX; i++){
		int sqrti = (int)sqrt(i);
		counter++;
		p[i] = counter;
		for (int j = 2; j <= sqrti; j++){
			if (i % j == 0){
				counter--;
				p[i] = counter;
				break;
			}
		}
	}
	int n;
	while (cin >> n){
		cout << p[n] << endl;
	}
	return 0;
}

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

int prime(int n) {
    if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (int i = 3; i <= n / i; i += 2) {
        if (n % i == 0) return 0;
    }
    return 1;
}

int main() {

    int C[1000000] = {0};
    for (int i = 2; i < 1000000; ++i) {
        C[i] = prime(i);
    }
    for (int i = 2; i < 1000000; ++i) {
        C[i] += C[i - 1];
    }

    int n;
    while (cin >> n) {
        cout << C[n] << endl;
    }

    return 0;
}

C++: #include<iostream>
using namespace  std;
bool isPrime(int p)
{
	bool flag = true;
	for (int i = 2; i * i <= p; i++)
	{
		if (p % i == 0)
		{
			flag = false;
			break;
		}
	}
	return flag;
}
int main()
{
	int n;
	while (cin >> n)
	{
		int count = 0;
		for (int i = 2; i <= n; i++)
		{
			if (isPrime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

int main(void){
  int n;
  short int p[1000000];
  p[0] = p[1] = 0;
  p[2] = 1;
  int ans = 0;
  bool flag;
  for(int i = 3; i <= 1000000; i ++){
    if(i % 2 != 0){
      flag = true;
      for(int j = 3; j * j <= i; j += 2){
	if(i % j == 0){
	  flag = false;
          break;
	}
      }
      if(flag)
	ans++;
    }
    p[i] = ans;
  }
  // cout << "end" << endl;
  while(cin >> n){
    cout << p[n] << endl;
  }
  return 0;
}

C++: #define _USE_MATH_DEFINES

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

using namespace std;

bool is_prime(int n)
{
	if (n == 2)
	{
		return true;
	}
	else if ((n == 1) || (n % 2 == 0))
	{
		return false;
	}

	int p = (int)sqrt(n);
	for (int i = 3; i <= p; i += 2)
	{
		if (n % i == 0)
		{
			return false;
		}
	}

	return true;
}

int main()
{
	vector<int> p;
	for (int i = 1; i < 1000000; i++)
	{
		if (is_prime(i))
		{
			p.push_back(i);
		}
	}

	int n;
	for (; cin >> n;)
	{
		int i;
		for (i = 0; i < p.size(); i++)
		{
			if (p.at(i) > n)
			{
				break;
			}
		}

		cout << i << endl;
	}
}

C++: #include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '
#define not true
#define prime false

using namespace std;

void init();
void func();

int main(void)
{
	
	func();

	return 0;
}


#define MAXIMUM 1000000
bool table[MAXIMUM];
int cnt[MAXIMUM];
#define not true
#define prime false

void init()
{
		table[0] = not;
	table[1] = not;
	for (int i = 2; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			for (int j = i * 2; j < MAXIMUM; j += i)
			{
				table[j] = not;
			}
		}
	}
	for (int i = 1; i < MAXIMUM; i++)
	{
		if (table[i] == prime)
		{
			cnt[i] = cnt[i - 1] + 1;
		}
		else
		{
			cnt[i] = cnt[i - 1];
		}
	}

}

void func()
{
	
	int n;

	init();

	while (cin >> n, !cin.eof())
	{
		cout << cnt[n] << endl;
	}

}

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

int main(){
  int n,m,p[999999];
  bool ip[1000000];
  for(int i=0;i<=1000000;i++) ip[i]=true;
  ip[0]=ip[1]=false;
  for(int i=2;i<=1000000;i++){
    if(ip[i]){
      p[m++]=i;
      for(int j=2*i;j<=1000000;j+=i) ip[j]=false;
    }
  }
  while(cin>>n){
    for(int i=0;i<=m;i++){
      if(p[i]>n){
	cout<<i<<endl;
	break;
      }
    }
  }
  return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data,i=0,j=2,k=0,l=0,kai[100]={0},s[10000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		{
			kai[k]=0;
		}
		else
		{
			for(i=2;i<data;i++)
				s[i]=i;
		
			for(i=2;i*2<data;i++)		
			{
				for(j=2;j*i<data;j++)				
					s[j*i]=0;
			}
			for(i=2;i<data;i++)
			{	
				if(s[i]!=0)
				{
					l+=1;
				}
			}
		}
		kai[k]=l;
		k+=1;
	}

  for(j=0;j<k;j++)
    printf("%d\n",kai[j]);
  return 0;
}

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

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    int temp = 0;
    while(scanf("%d",&n)==EOF){
        if(n==1){
            printf("%d",0);
        }else{
            for(int i=2; i<=n; i++ ){
                temp+=sosuu(i);
            }
            printf("%d",temp);
        }
    }
    
    
}

int sosuu(int n){
    for(int i=2; i<n; i++){
        if(n%i == 0){
            return 0;
        }
    }
    return 1;
}

C++: #include <cstdio>
#include <cstdlib>
#include <iostream>
#include <math.h>

using namespace std; 

long int a,b,loop,hasil;
long int lo;
long int hi;



int main()
{
	while(scanf("%ld",&hi)!= EOF)
	{
	lo=2;
	hasil=0;
		while(lo<=hi)
		{
			for(a=2;a<=lo;a++)
			{
				if(a==lo)
				{
					hasil++;
					break;
				}
				else if(lo%a==0)
				{
					break; 
				}
				else 
				{
				}
			}
			lo=lo+1; 
		}
	printf("%d\n",hasil);
	}
	return 0; 
}