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 <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <tuple>
#include <set>

using namespace std;
using ll = long long;
using ull = unsigned long long;
#define out(S) cout<<(S)<<endl;
#define REP(i,b) for(size_t i=0;i<(b);i++)
#define rREP(i,b) for(int i=(b)-1;i>=0;i--)
#define FOR(i,a,b) for(size_t i=(a);i<(b);i++)
#define rFOR(i,a,b) for(int i=(b)-1;i>=0;i--)
#define Foreach(item,collection) for(auto item:collection)
#define mod(i) ((i) % (ll)(1e9 + 7))
ll modpow(ll i, ll j) { ll tmp = 1; while (j) { if (j % 2)tmp = mod(tmp*i); i = mod(i*i); j /= 2; }return tmp; }
#define divmod(a,b) (mod(a * modpow((ll)b,(ll)(1e9 + 5))))
#define Yes out("Yes")
#define No out("No")
#define NO out("NO")
#define YES out("YES")
#define INF 1e10;
#define ShowAll(collection) for(auto i:collection){out(i);}
#define IfOut(condition,text) if((condition)){out(text);return 0;}
#define IfeOut(condition,itext,etext) if(condition){out(itext);return 0;}else{out(etext);return 0;}
#define Select(collection,condition,result) Foreach(i,collection){result+=condition;}
#define GetAuto(_N,vect) {cin>>N;vect.resize(N);REP(i,_N){cin>>vect[i];}}
void removeAt(string& s, int index) { s.erase(index, 1); }
template<typename T> void removeAt(vector<T>& v, int index) { v.erase(v.begin() + index); }
ll manhattanDistance(ll x1, ll y1, ll x2, ll y2) { return (abs(x2 - x1) + abs(y2 - y1)); }
#define beginend(vec) (vec).begin(),(vec).end()
vector<ll> sieveOfEratosthenes(int max) {ll prime;double sqrtmax = sqrt(max);vector<ll> primeVec, searchVec;FOR(i, 2, max + 1) searchVec.push_back(i);do{prime = searchVec[0];primeVec.push_back(prime);auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });searchVec.erase(itr, searchVec.end());} while (prime < sqrtmax);primeVec.reserve(primeVec.size() + searchVec.size());primeVec.insert(primeVec.end(), beginend(searchVec));return primeVec;}


int main() {
	ll nn;
	map<ll, ll> ans;
	map<ll, bool> box;
	vector<ll> input, output;
	while (cin >> nn)
	{
		input.push_back(nn);
		box[nn] = false;
	}
	box[1] = true;
	ans[1] = 0;
	Foreach(n, input) {

		if (box[n]) {
			output.push_back(ans[n]);
			continue;
		}
		int prime;
		double sqrtmax = sqrt(n);
		vector<ll> primeVec, searchVec;
		FOR(i, 2, n + 1) searchVec.push_back(i);
		do
		{
			prime = searchVec[0];
			primeVec.push_back(prime);
			auto itr = remove_if(beginend(searchVec), [=](ll x)->bool {return x%prime == 0; });
			searchVec.erase(itr, searchVec.end());
		} while (prime < sqrtmax);
		ans[n] = (primeVec.size() + searchVec.size());
		output.push_back(ans[n]);
		box[n] = true;
	}

	ShowAll(output);
	return 0;
}

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

bool isPrime(int k) {
    for(int i = 2; i < k/2; i++){
        if(k%i == 0) 
            return false;
    }
    return true;
}

int main() {
    int n;
    int count = 0;
    while(cin>>n) {
        for(int i = 2; i <= n;i++) {
            if(isPrime(i))
                count++;
        }
        cout<<count<<endl;
    }
    
    return 0;
}

C++: #include <stdio.h>

const int MAX_V = 10000;
int prime[MAX_V+1];

void init(){
    int i, k, v;
    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;
            }
        }
    }   
}

int isprime(int n){
    return prime[n];
}

int main(){
    init();
    int num;
    while(scanf("%d", &num)){
        int count=0;
        for(int i=2; i<=num; i++){
            if(isprime(i)==1)
                count++;
        }
    printf("%d\n", count);
    }
    return 0;
}

C++: #include<iostream>

int main(){

	bool data[100001];

	for (int i = 0; i < 100001; i++)
		if (i!=2&&i % 2 == 0)
			data[i] = false;
		else
			data[i] = true;

	int in;

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

	while (true) {

		std::cin >> in;

		int res = 0;

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

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

	}

		return 0;
}

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

using namespace std;


int main() {
	int n;
	bool p[1000000];

	p[0] = 0;
	p[1] = 0;

	for(int i = 2; i <= 999999; i++) {
		p[i] = true;
	}

	for(int i = 2; i * i <= 999999; i++) {
		for(int j = i; j * i <= 999999; j++) {
			p[j * i] = false;
		}
	}

	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			if(p[i] == true) {
				count++;
			}
		}

		cout << count << endl;
	}
}

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

int main() {
  cin.tie(0);   //cinとcoutとの結びつきの解除をする
  ios::sync_with_stdio(false);    //stdioとの同期を解除する

  int x;
  int count_cin = 0;
  while(true){
    cin >> x ;
    count_cin++;

    if(count_cin == 30) break;


    bool array[max_n];

    for(int i = 0; i < max_n; i++) {
      array[i] = true;
    }

    array[0] = false;
    array[1] = false;
    for(int i = 2; i < max_n; i++) {
      for(int j = 2; j < max_n; j++) {
        if(i * j > max_n) break;
        array[i * j] = false;
      }
    }

    int count_sosu = 0;

    for(int i = 0; i < x; i++) {
      if(array[i] == true) count_sosu++;
    }

    cout << count_sosu << endl;
  }

}

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

typedef long long LL;
using namespace std;

const int X = 1000001;
bool Find[X];

void init(){
  for(int i=0;i<X;i++){
    Find[i] = false;
  }
  for(int i=2;i<=sqrt(X);i++){
    if(Find[i])continue;
    for(int j=i+1;j<X;j++){
      if(Find[j])continue;
      if(j%i==0)Find[j]=true;
    }
  }
}

int main(){
  init();
  int n;
  while(cin >> n){
    int answer = 0;
    for(int i=2;i<n+1;i++){
      cout << Find[i] <<endl;
      if(!Find[i])answer++;
    }
    cout << answer << endl;
  }
  return 0;
}

C++: 
#include<iostream>
#pragma warning(disable:4996)
using namespace std;
int n,t;
int d[10000000];
bool is_prime(int n){
	for (int i = 2; i*i <= n; i++)
	if (n%i == 0)   return false;   return true;

}
int main(){
	for (int i = 0; i < 10000000; i++)
		d[i] = 1;
	for (int i = 2; i<100; i++){
		if (is_prime(i))
		{
			int j = 2;
			while (i*j < 10000000){
			     d[i*j] = 0;
				j++;
			}
		}}
	while (scanf("%d", &n) != EOF){
		t = 0;
		for (int i = 2; i <= n; i++){
			if (d[i] == 1)
				t++;
		}
		cout << t << endl;

	}


}

C++: #include <iostream>
using namespace std;
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
const int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
const pcount[MAX_V+1];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}