Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

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

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
int main()
{
	while (cin)
	{
		string tmpstr;
		int tmp;

		getline(cin, tmpstr);

		tmp = atoi(tmpstr.c_str());

		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;

		//if (cin.eof()) { break; }
	}

	return 0;
}

C++: #include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    while(~scanf("%d",&n))
    {
        int prime[n+1];
        for(int i=0;i<=n;i++)
            prime[i]=1;
            prime[0]=0;
            prime[1]=0;
        for(int i=2;i*i<=n;i++)
             if(prime[i]==1)
        {
            for(int j=2;j*i<=n;j++)
            prime[i*j]=0;
        }
        int c=0;
        for(int i=0;i<=n;i++)
        {
            if(prime[i]==1)
                c++;
        }
        printf("%d\n",c);
    }

}

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

long long int a[1000000];

int main(){

  long long int n;

  for(long long int i=2;i*i<1000000;i++){
    if(a[i]==0){
      for(long long int j=i+i;j<1000000;j+=i) a[j]=1;
    }
  }

  while(cin >> n){

    long long int count=0;

    for(long long int i=2;i<n;i++){
      if(a[i]==0) count++;
    }

    cout << count << endl;

  }
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    int c[max];
    int so=0;
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        if(b[i]!=0){
            for(int j=2; j<=max; j++){
                if(i*j<=max){
                    b[i*j]=0;
                }else{
                    j=max;
                }
            }
        }
    }
    
    for(int i=0; i<=max; i++){
        if(b[i]!=0){
            c[so]=i;
            so++;
        }
    }
    
    

    for(int i=0; i<num; i++){
        for(int j=0; j<so; j++){
            if(c[j]<=a[i][0]){
                a[i][1]++;
            }else{
                j=so;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt;

    while (scanf("%d", &n) && n!=EOF){
        cnt=0;
        for (int i=2; i<n; i++){
            if (IsPrime(i)) cnt++;
        }
        printf("%d\n", cnt);
    }
    return 0;
}

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

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

using namespace std;

int Count(bool [], int, int);

int main() {
  const int N = 1000000;
  bool num[N];
  for (int i = 0; i < N; i++)
    num[i] = true;

  const int N_MAX = 999999;
  const double MAX = sqrt(N_MAX);
  for (int i = 2; i <= MAX; i++) {
    if (num[i]) {
      for (int j = i; i*j <= N_MAX; j++) {
        num[i * j] = false;
      }
    }
  }

  int data;
  while (cin >> data) {
    cout << Count(num, 2, data) << endl;
  }
}

int Count(bool data[], int begin, int end) {
  int count = 0;
  for(int i = begin; i <= end; i++)
    if (data[i])
      count++;

  return count;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
            return false;
    }
    return true;
}
int main() {
  int n;
  int sum[1000000];
  sum[0]=0;
  sum[1]=0;
  sum[2]=1;
  for(int i=3;i<1000000;i++) {
    sum[i]=sum[i-1];
    if(IsPrime(i)) 
      sum[i]++;
 }
  while(cin>>n)
    cout<<sum[n]<<endl;
  return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
bool prime(int n)
{
    for(int i=2;i<=sqrt(n);i++)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int main()
{
    int n,c,i;
    while(scanf("%d",&n)!=EOF)
    {
        c=0;
        for(i=2;i<=n;i++)
        {
            if(prime(i))
                c++;
        }
        cout<<c<<endl;
    }
    return 0;
}

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

using namespace std;

int n,np[1000000];
bool isp[1000000];

int main()
{
    memset(isp,1,sizeof isp);
    isp[0]=isp[1]=0;
    for(int i=2;i<1000;i++)
        if (isp[i]) for(int j=i*i;j<1000000;j+=i) isp[j]=false;
    for(int i=1;i<1000000;i++) np[i]+=np[i-1]+isp[i];
    while (~scanf("%d",&n)) printf("%d\n",np[n]);
    return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
	while (1)
	{
		int tmp;

		cin >> tmp;

		vector<int> prime;

		for (int i(2); i <= tmp; ++i)
		{
			for (vector<int>::iterator i2(prime.begin()), n2(prime.end()); i2 != n2; ++i2)
			{
				if ((i % *i2) == 0)
				{
					goto nx;
				}
			}

			prime.push_back(i);
		nx:;
		}

		cout << prime.size() << endl;

		if (cin.eof()) { break; }
	}

	return 0;
}

C++: #include <cstdio>
#include <vector>
#include <cmath>
#include <ctime>

using namespace std;

int main()
{
	int n;
	int len = 1;
	vector<int> prime;
	
	//unsigned long t = time(NULL);
	prime.push_back(2);
	for (int i = 3; i < 1000000; i += 2){
		int j;
		for (j = 0; j < len && prime[j] < i / 2; j++){
			if (i % prime[j] == 0){
				break;
			}
		}
		if (j >= len || prime[j] >= i / 2){
			prime.push_back(i);
			len++;
		}
	}
	//printf("%lu\n", time(NULL) - t);
	while (scanf("%d", &n) != EOF){
		int count;
		
		for (count = 0; prime[count] <= n; count++){//;
			//printf("%d\n", prime[count]);
			;
		}
		printf("%d\n", count);
	}
	
	return 0;
}

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++;
    }
    std::cout << count << "\n";
    if(c == EOF) break;
  }
  return 0;
}