Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

func nextInt() int {
	i, e := strconv.Atoi(scanner.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func check(n int) int {
	eratos := make([]bool, n+1)
	cnt := 0
	for i := 2; i < len(eratos); i++ {
		if !eratos[i] {
			cnt++
			for j := i*i; j < len(eratos); j += i {
				eratos[j] = true
			}
		}
	}
	return cnt
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		fmt.Println(check(n))
	}
}

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

using namespace std;


int main(int argc, const char * argv[]) {
    // insert code here...
    
    int maxNumber;
    int countPrime=0;
    
    int prime[999999]={0};
    
    prime[0]=-1;
    prime[1]=-1;
    

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

    while(cin >> maxNumber){
        countPrime=0;
        for(int x=2;x<maxNumber+1;x++){
            if(prime[x]==0){countPrime++;}
        }
        cout << countPrime << endl;
    }


    return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

    while(cin >> n){
      prime = 1;
      for(int i=3; i <= n; i++){
        int j = 2;
        while(i%j !=0) j++;
        if(j == i) prime++;
      }
      cout << prime << endl;
    }
    return 0;
}

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

using namespace std;

int A[100];
int Pream(int n)
{
	int kusa = (int)sqrt((double)n);
	int mama = 0;

	for (int i = 0; i < n; i++)
		A[i] = 1;  // ??¨????????°???1????????????
	A[0] = 0;    // 1????´???°??§?????????

	for (int i = 1; i < kusa; i++) {
		if (A[i] == 1)   // prime[i]????´???°??????
		{
			for (int j = (i + 1); (i + 1) * j <= n; j++)
				A[(i + 1) * j - 1] = 0;  // ?´???°????????°????´???°??§?????????
		}
	}
	for (int i = 0; i < n; i++)
		if (A[i] == 1)  // 1????????£???????????????????´???°
			mama++;

	return mama;
}

int main()
{
	int n;
	cin >> n;
	while (n != -1)
	{
		cout << Pream(n) << endl;
		cin >> n;
	}
	return 0;
}

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

int main(){

int n;
while(cin>>n){
    int i=0;
    int count=0;
    for(i=1;i<=n;i++)
       if(n%i==0)
           count++;
    cout<<count<<endl;
}

return 0;
}

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

int num,sqt,cnt;

int main()
{
    while(cin>>num)
    {
       sqt=sqrt(num+0.5);
       if(num<=3)cnt=num-1;
       else{cnt=num-2;}
       for(int i=2;i<sqt;i++)
       {
           for(int j=i*2;j<=num;j+=i)
            {
                cnt--;
            }
       }
        cout<<cnt<<endl;
    }
}

C++: #include <iostream>

using namespace std;
 
#define MAX 1000000
 
int main()
{
    int prime[MAX];
    fill(prime, prime + MAX, 1);
    prime[0] = prime[1] = 0;
    for (int i = 2; i < MAX; i++) {
        if (prime[i]) {
            for (int j = 2*i; j < MAX; j += i) {
                prime[j] = 0;
            }
        }
    }
    
    for (int i = 1; i < MAX; i++) {
	prime[i] = prime[i] + prime[i-1];
    }
    
    int N;
    while (cin >> N) {
	cout << prime[N] << endl;
    }
    return 0;
}

C++: //
//  main.cpp
//  gcd
//
//  Created by Syngnath on 15/12/16.
//  Copyright ? 2015年 Syngnath. All rights reserved.
//
#include <iostream>
#include <cmath>
#include <cstdio>



int primeNumDector(int MAX) {
    int counter;
    bool isPrime[MAX];
    for (int i = 0; i <= MAX;i++)
        isPrime[i] = true;
    
    isPrime[0] = isPrime[1] = 0;
    
    for (int i = 2;i <= (int)sqrt(MAX); i++) {
        if(isPrime[i]) {
            for ( int j = 2*i; j <= MAX;j += i)
                isPrime[j]=0;
        }
    }
    
    for(int i = 2;i <= MAX;i++)
        if(isPrime[i])
            counter++;
    
    return counter;
}


int main()
{
    int n;
    while(scanf("%d",&n) != EOF) {
        int ans = primeNumDector(n);
        printf("%d\n",ans);
    }
}

C++: #include <stdio.h>

#define DATA 30

int main(void)
{
	int h[DATA], k, yakusuu;

	for(int x = 0; x < DATA; x++) {
		k = 0;

		scanf("%d", &h[x]);

		for(int i = 1; i <= h[x]; i++) {
			yakusuu = 0;

			for(int j = 1; j <= i; j++) {
				if(i % j == 0) yakusuu++;
			}

			if(yakusuu == 2) k++;
		}

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

	return 0;
}

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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

vector<ll> isPrime;

vector<int> sieveOfEratosthenes(int n) {
    isPrime.resize(n + 1, true);
    isPrime[0] = false;
    isPrime[1] = false;
    vector<int> res;
    for (int i = 2; i <= n; i++) {
        if (isPrime[i]) {
            res.push_back(i);
            for (int j = i * 2; j <= n; j += i) {
                isPrime[j] = false;
            }
        }
    }
    return res;
}


void Main() {
    ll N;
    while (cin >> N) {
        cout << sieveOfEratosthenes(N).size() << '\n';
    }

}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

C++: #include <iostream>
 
int main(){
    int n, count;
    while(std::cin >> n){
        count = 0;
        for(int i=3; i<=n; i++){            // check whether i is a prime number greater than 3
            for(int j=2; j<i; j++){         // judge from whether j is an i's divisor
                if(i % j == 0)              // if j is an i's divisor
                    break;                  // exit the j-loop & start to check suc(i)
                if(j == i - 1)              // when the j-loop lasts until i-1
                    count++;                // j is a prime!
            }
        }
        if(n>=2)
            count++;                        // 2 is also a prime
        std::cout << count << std::endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a ; i ++)
#define loop(i,a,b) for(int i = a ; i < b ; i ++)
const int M = (1e6);
bool p[M];
void isPrime(){
  rep(i,M)p[i] = true;
  p[0] = p[1] = false;
  loop(i,2,M){
    if(p[i])
      for(int j = i + i ; j < M ; j += i)
	p[j] = false;
  }
}
int main(void){
  isPrime();
  int n;
  while(cin>>n){
    int res = 0;
    rep(i,n+1)res += p[i];
    cout<<res<<endl;
  }
}