Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

func isPrime(n int) bool {
	for i := 2; i*i <= n; i++ {
		if n % i == 0 {
			return false
		}
	}
	return true
}

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b) - 1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)

#define PB push_back
#define INF INT_MAX/3
#define ALL(a) (a).begin(),(a).end()
#define CLR(a) memset(a,0,sizeof(a))

typedef long long int ll;

using namespace std;

int main(){
    vector<int> primes;
    primes.PB(2);
    FOR(i,3,10000){
	bool flg = true;
	REP(j,primes.size()) if(i % primes[j] == 0 ) flg = false;
	if(flg) primes.PB(i);
    }

    int n;
    while(true){
	cin >> n;
	if(cin.eof())break;
	int res = upper_bound(ALL(primes),n) - primes.begin();
	cout << res << endl;
    }

    return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
#define MAX_N 100001
int main(){
	int n;
	while(cin >> n){
		vector<int> vec;
		vector<int>::iterator it =vec.begin();
		for(int i=2;i<=n;i++){
			int flag=0;
			it =vec.begin();
			while(it!= vec.end()){
				if(i% *it==0){
					flag=1;
					break;
				}
				it++;
			}
			if(!flag)vec.push_back(i);
		}
		it =vec.begin();
		//while(it!= vec.end()){
		//	cout<<*it<<endl;
		//	it++;
		//}
		cout << vec.size()<<endl;
	}
	return 0;
}

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

int main(){
 int i,j,n,count,flg;
 scanf("%d",&n);
 for(i=2,count=0;i<=n;i++){
  for(j=2,flg=1;j<=i/2;j++)
   if(i%j==0){ flg=0; break; }
  count+=flg;
 }
 printf("%d\n",count);
 return 0;
}

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

#define MAX 1000000
#define NIL -1

int primes[MAX];

bool isPrime(int n)
{
    if (n <= 1) {
        primes[n] = 0;
        return false;
    }
    if (n <= 3) {
        primes[n] = 1;
        return true;
    }
    if (n % 2 == 0 || n % 3 == 0) {
        primes[n] = 0;
        return false;
    }
    for (int i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0) {
            primes[n] = 0;
            return false;
    }
    primes[n] = 1;
    return true;
}

int main()
{
    for (int i = 1; i <= MAX; i++) primes[i] = NIL;
    int N, sum;
    while(std::scanf("%d", &N) != EOF) {
        sum = 0;
        for (int i = 2; i <= N; i++) {
            if (primes[i] != NIL) {
                if (primes[i] == 1) sum++;
            }
            else {
                if (isPrime(i)) sum++;
            }
        }
        std::printf("%d\n", sum);
    }
    return 0;
}

C++: #define _USE_MATH_DEFINES
#define llint long long
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;

int pn = 0;
int p[1000000];
void getsosu(int Max) {
    for(int i = 2; i <= Max; i++) {
        bool flg = true;
        for(int j = 0; j < pn; j++) {
            if(p[j] * p[j] > i) break;
            if(i % p[j] == 0) {
                flg = false;
                break;
            }
        }
        if(flg) p[pn++] = i;
    }
}

int main() {
    getsosu(999999);

    int n;
    while(cin >> n) {
        int i = 0;
        while(p[i] <= n) i++;
        cout << i << endl;
    }
    return 0;
}

C++: <?php
$max=1000000;
$maxR=floor(sqrt($max));

$ch=[0,0,1,1];

for($i=4;$i<$max;$i+=2){$ch[]=0;$ch[]=1;}

for($i=3;$i<$maxR;$i+=2) if($ch[$i]) for($j=$i+$i;$j<$max;$j+=$i) $ch[$j]=0;

for($i=3;$i<$max;$i++) $ch[$i]+=$ch[$i-1];

while(fscanf(STDIN,"%d",$n)) printf("%d\n",$ch[$n]);

C++: #include <iostream>
#include <queue>
#include <vector>
#include <math.h>
#include <algorithm>
#include <iomanip>
#include <string>
using namespace std;

int main(){
	int max = 1000000;
	bool is_prime[max] = {};
	for (int i = 2; i < max; ++i) {
		is_prime[i] = 1;
	}
	for (int i = 0; i < max; ++i) {
		if (is_prime[i]) {
			for (int j = i; j < max; j += i) {
				is_prime[j] = 0;
			}
		}
	}
	int num_prime[max] = {};
	for (int i = 1; i < max; ++i) {
		num_prime[i] = num_prime[i-1] + is_prime[i];
	}
	int n;
	while (cin >> n) {
		cout << num_prime[n] << endl;
	}
	return 0;
}

C++: 
#include <cstdio>
#include <utility>
#include <queue>
#include <vector>
#include <iostream>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>

using namespace std;

int prime[999999];
bool is_prime[1000000];

int sieve(int n){
  int p=0;
  for(int i=0; i<=n; i++) is_prime[i]=true;
  is_prime[0]=is_prime[1]=false;
  for(int i=2; i<=n; i++){
    if(is_prime[i]){
      prime[p++]=i;
      for(int j=2*i;j<=n;j+=i) is_prime[j]=false;
    }
  }
  return p;
}

int main(){

int n;

while(cin>>n){
  cout<<sieve(n)<<endl;
}

}

C++: #include<iostream>
#include<cmath>
#define MAX 1000000
using namespace std;
int main(){
	bool num[MAX] = {false,false};
	for(int i=2;i<MAX;i++){
		num[i] = true;
	}
	for(int i=2; i<sqrt(MAX); i++){
		if(num[i]){
			for(int l=i*2;l<MAX;l+=i){
				num[l] = false;
			}
		}
	}
	int n;
	while(cin >>n){
		int ans = 0;
		for(int i=0;i<=n;i++){
			if(num[i]){ans++;}
		}
		cout <<ans<<endl;
	}
	return 0;
}

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

int main() {
	// your code goes here
	int nu[30];
	int num;
	int count = 0;
	int max = 29;
	for(int x=0;x<30;x++){
		nu [x] = -1;
		cin >> nu[x];
		if (nu[x] == -1) {
			max = x;
			break;
		}
	}
	for (int y=0;y<max;y++) {
		num = nu[y];
		count = 0;
		
		for (int i = 1;i<=num;i++) {
		if(i%2==0) {
			//cout <<"2: "<<i<<endl;
			count ++;
			continue;
		}
		for (int j=3;j<(int)sqrt(i)+1;j=j+2) {
			if (i%j==0) {
				count ++;
				//cout <<"i: "<<i<<" j: "<<j<<endl;
				break;
			}
		}
	}
	cout << (num-count) <<endl;
	//cout << endl;
	}
	return 0;
}

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

int main(){
	int n, temp, counter;
	temp = 0;
	counter= 0;
	while(cin >> n){
		vector<int> num(n);
		num[0], num[1] = 1;
		for(int i = 0; i < n; i++){
			if(num[i] == 0){
				for(int j = 0; temp < n; j++){
					temp = i * j;
					num[temp] = 1;
					counter++;
				}
			}
		}
		cout << counter << endl;
	}
	return(0);
}

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

int main()
{
  int n;
  while(cin >> n){
    double nd=(double)n;
    int root=(int)sqrt(nd);
    int count=0;
    for(int i=2;i<=n;i++){
      int j;
      for(j=2;j<=root;j++){
        if(i%j==0) break;
      }
      if(j==root) count++;
    }
    cout << count << endl;
  }
  
  return 0;
}

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

using namespace std;

int A[1000000];
int Eratosthenes(int n)
{
	int mama = 0;
	for (int i = 0; i < n; i++)
	{
		A[i] = 1;
	}
	for (int i = 2; i < sqrt(n); i++)
	{
		if (A[i])
		{
			for (int j = 0; i*(j + 2) < n; j++)
			{
				A[i*(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < n; i++)
	{
		if (A[i])
		{
			mama++;
		}
	}
	return mama;
}

int main()
{
	int n;
	cin >> n;
	cout << Eratosthenes(n) << endl;
	return 0;
}

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

int main(void) {
    int N=999999;
    int p[N] , s[N];
    p[0]=0;
    for (int i=1; i<N; i++){
        p[i] = 1;
        s[i] = 0;
    }
    for (int i=1; i<N; i++){
        cout << i;
        if (p[i]==1){
            int n=i+1 , m=2*n;
            while (m<=N){
                p[m-1] = 0;
                m += n;
            }
        }
    }
    
    for (int i=1; i<N; i++){
        s[i] = s[i-1]+p[i];
    }
    int n;
    while (1){
        cin >> n;
        cout << s[n-1] << endl;
    }
    return 0;
}