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<string>
using namespace std;
int main(){
	int n,a[9];
	a[0]=9592;
	a[1]=17984;
	a[2]=25997;
	a[3]=33860;
	a[4]=41538;
	a[5]=49098;
	a[6]=56543;
	a[7]=63951;
	a[8]=71274;
	while(cin>>n){
		int count=0;
		int i=0;
		while(true){
			if((i+1)*100000<=n)
				count=a[i];
			else
				break;
			i++;
		}
		if(n<100000){
			count=1;
			for(int j=3;j<=n;j++){
			bool t=false;
			for(int k=2;k<1+(double)sqrt((double)j);k++){
				if(j%k==0)
					t=true;
			}
			if(t==false)
				count++;
		    }
		}
		else{
		    for(int j=(i)*100000+1;j<=n;j++){
			    bool t=false;
			    for(int k=2;k<1+(double)sqrt((double)j);k++){
				    if(j%k==0)
				        t=true;
			    }
			    if(t==false)
				    count++;
		    }
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: #include <stdio.h>
int main()
{
  int i,j,cou=0,n;
  while(scanf("%d",&n)!=EOF){
    cou=0;
    for(i=2;i<=n;i++){
      if(i==2){
	cou++;
	continue;
      }
      for(j=2;j<i;j++){
	if(i%j==0)break;
	if(j==i-1)cou++;
      }
    }
    printf("%d\n",cou);
  }
  return 0;
}

C++: #include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

string str;

int main()
{
  int n,i,j;
  while(scanf("%d",&n)!=EOF){
    vector<int> v(1000000,0);
    for(i=2;i<n+1;i++){
      if(v[i])continue;
      for(j=2;i*j<n+1;j++)
	v[i*j]=1;
    }
    int sum=0;
    for(i=2;i<n+1;i++)
      if(v[i]==0)sum++;
    cout<<sum<<endl;
  }
}

C++: #include <iostream>

using namespace std;

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

int main(int argc, char **argv)
{
	int n, c;
	
	while(cin >> n){
		c = 0;
		for(int i = 2; i <= n; i++){
			if(prime(i) == 1){
				c++;
			}
		}
		
		cout << c << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>
int main(){
	int a,b,c,n;
	0<n<1000000;
	c=0;
	scanf("%d",&n);
	for(a=1;a<=n;a++){
		for(b=2;b<=n;b++){
			if(a%b==0&&a!=b){
				break;
			}else if(a%b==0&&a==b){
				c++;
			}else{
			}
		}
	}
	printf("%d\n",c);
	return 0;
}

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

#define max 1000000

int main(){
	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 + 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++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	int n;
	cin >> n;
	for (int i = 2; i<=n; i++){
		if (!vis[i]){
			
			prime[i] = 1;
			for (int j = i+i; j<=n; j += i){
				vis[j] = 1;
				prime[j] = 0;
				
		}
	}
	int sum = 0;
	for (int i = 2; i <= n; i++){
			if (prime[i]){
				sum++;
			}
		}
		cout << sum << endl;
	return 0;
}

C++: #include<iostream>

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=(int)sqrt((double)n);++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

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

C++: #include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
using namespace std;
typedef pair<int,int> P;
const int INF = (int)((unsigned int)-1>>1);


int main(){
    vector<int> prime;
    prime.push_back(2);

    for(int i=3;i<=999999;i+=2){
        bool is_prime = true;
        for(int j=0;j<prime.size();j++){
            if (prime[j]*prime[j] > i) break;
            if (i % prime[j] == 0){
                is_prime = false;
                break;
            }
        }
        if(is_prime){
            prime.push_back(i);
        }
    }

    int n;
    while(cin >> n){
        int ans = 0;
        for(int j=0;j<prime.size();j++){
            if (prime[j] > n) break;
            ans++;
        }
        cout << ans << endl;
    }

    return 0;
}

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

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

	for(int i=2 ; i<=sqrt((long double)MAX)+1 ; i++){
		if(p[i]){
			for(int j=i*2 ; j<=MAX ; j+=i){
				p[j] = false;
			}
		}
	}

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

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

using namespace std;
#define MAX_NUM 10000000
vector<int> p;
int flag[MAX_NUM/32+1];

//sieve eratosthenes
void setPrime(vector<int> &p){

    for(int i=1;2*i*(i+1)<(MAX_NUM>>1);++i){

        if(flag[i>>5] & (1<<(i%32)))continue;
        //(2*j+1) == (2*i+1)*(2*i+1)
        //(2*i+1)*(2*i+1) -> (2*i+1)*(2*(i+1)+1) -> ... set not prime
        for(int j=2*i*(i+1); j<(MAX_NUM>>1); j+=2*i+1)
            flag[j>>5] |= (1<<(j%32));

    }

    p.push_back(2);
    for(int i=1;2*i+1<=MAX_NUM;++i){
        for(;flag[i>>5] & (1<<i);++i);
        if(2*i+1>MAX_NUM)break;
        p.push_back(2*i+1);
    }

}

int ans[1000001];
int cnt = 0;

int main(){

    vector<int> primes;
    setPrime(primes);

    for(int i=0;i<=1000000;++i){

        if(primes[cnt]==i)++cnt;

        ans[i]=cnt;

    }

    int N;
    while(cin>>N){

        cout << ans[N] << endl;

    }

    return 0;
}

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

#pragma warning(disable:4996)

int main()
{
	int DataSet,nCnt,nCnt2,In,Total,Count;

	Total = 0;
	DataSet = 0;

	for (DataSet = 0; DataSet <= 30; DataSet++)
	{
		scanf("%d", &In);
		Total = 1;

		if (In > 2)
		{
			for (nCnt = 3; nCnt <= In; nCnt += 2)
			{
				Count = 0;

				for (nCnt2 = nCnt; nCnt2 >= 2; nCnt2--)
				{
					if (nCnt%nCnt2 == 0)
					{
						if (nCnt != nCnt2)
						{
							Count++;
							break;
						}
					}
				}
				if (Count == 0)
					Total++;
			}
		}

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


	return 0;
}

C++: #include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<iostream>
#include<math.h>
using namespace std;
  
int main(){
int p;
while(cin>>p){	int n[100001],i,j,a=0;
	for(i=0;i<100001;i++){
		n[i]=0;
	}
	n[0]=1;n[1]=1;
	for(i=2;i<100000;i++){
		if(n[i]==0){
			j=2;
			while(i*j<100000){
				n[i*j]=1;
				j++;
			}
		}
	}
	for(i=1;i<p;i++){
		if(n[i]==0){
			a++;
		}
	}
	cout<<a<<endl;
}
	return 0;
}