Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

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

using namespace std;

#define N 100000

int main(){

    bool primes[N];
    int  n; 

    fill(primes, primes + (sizeof primes / sizeof *primes), true);
   
    primes[0] = false;
    primes[1] = false;
    
    for(int i = 2; i < N; ++i){
        if(primes[i]){
            for(int j = i + i; j < N; j += i)primes[j] = false;
        }
    }

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

C++: #include<iostream>

using namespace std;

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

int main(void)
{
	int n;
	while(cin>>n){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(sosu(i))
				ans++;
		}
		cout<<ans<<endl;
	}
}

C++: #include <stdio.h>

char num[1000050];

void check(void)
{
	int i, j;
	
	num[0] = 1;
	num[1] = 1;
	num[2] = 0;
	
	for (i = 2; i < 1000000; i++){
		if (num[i] == 0){
			j = 2;
			while (i * j < 1000000){
				num[i * j] = 1;
				j++;
			}
		}
	}
}
		
int main()
{
	int i, n, sum;
	
	check();
	
	while (scanf("%d", &n) != EOF){
		
		sum = 0;
		
		for (i = 0; i <= n; i++){
			
			if (num[i] == 0)
			sum++;
		}
		
		printf("%d\n", sum);
	}
	
	return (0);
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


int f(int a){
	if(a==1) return 0;
	for(int i=2;i<=sqrt((double)a);i++){
		if(!(a%i)){
			return 0;
		}
	}
	return 1;
}
bool solve(){
	int n;
	int nmax=0;
	vector<int> k;
	while(cin>>n){
		k.push_back(n);
		if(nmax<n) nmax = n;
	}
	
	vector<int> res(nmax+1);
	int cnt=0;
	for(int j=2;j<=nmax;j++){
		cnt += f(j);
		res[j] = cnt;
	}	
	for(int i=0;i<k.size();i++){
		cout<< res[k[i]]<< endl;
	}
		
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}

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

bool prime(int n);

int main(void) {
	using namespace std;
	int x;
	int count;
	while (cin >> x) {
		count = 0;
		for (int i = 2; i <= x; i++) {
			if (prime(i))count++;
		}
		cout << count << endl;
	}
	return 0;
}

bool prime(int n) {
	if (n % 2 == 0 && n != 2) {
		return false;
	}
	else {
		for (int i = 3; i <= pow((double)n, 0.5); i+=2) {
			if (n % i == 0)return false;
		}
	}

	return true;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(void){
int unti[1000002] = {0};
fill(unti,unti + 1000001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000001;a++)
{
    if((a * n  ) < 1000001 ) unti[a * n]++;
}
}
}
int b;
for(int i;i <= 31;i++){
cin >> b

int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
}
return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
  int NUM = 1000000;
  bool prime[NUM];
  prime[0] = false;prime[1] = false;
  for(int i=2;i<NUM;i++)prime[i] = true;
  for(int i=2;i*i<NUM;i++)
    for(int k=2;i*k<NUM;k++)
      prime[i*k]=false;

	int primeNum[NUM];
	for(int i=0,c=0;i<NUM;i++){
		prime[i]&&c++;
		primeNum[i] = c;
	}
	for(int n;cin>>n;cout<<primeNum[n]<<endl);
}

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

int main(){
int n,a;
int ans;
while(cin>>n){
for(int i=2;i<n+1;i++){
for(int j=2;j*j<i+1;j++){
a=i%j;
if(a==0){ans++; break;}
}}
cout<<ans<<endl;}}

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

void extendPrim(vector<int> &prims,int n){
	if(prims.back()>=n)return;
	int i = prims.back();
	while(i++ <=n){
		for(auto it=prims.begin();it!=prims.end();it++){
			if(i % *it==0){break;}
			if(*it * *it > i){prims.push_back(i);break;}
		}
	}
}

int main(){
	vector<int> vec={2};
	//extendPrim(vec,100);
	int n;
	
	while(cin>>n){
		extendPrim(vec,n);
		auto i = lower_bound(vec.begin(),vec.end(),++n);
		cout << i-vec.begin() << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<map>
#include<queue>
#include<cmath>
#include<stack>
#include<vector>
#include<cstdio>
#define MAXN 2555
#define INF 0x3f3f3f3f
#define v first
#define b second
using namespace std;
const int N = 1000000;
bool prime[N];
int p[N],tot=0;
void init(){
    for(int i = 2; i < N; i ++) prime[i] = true;
    for(int i = 2; i < N; i++){
        if(prime[i]) p[tot ++] = i;
        for(int j = 0; j < tot && i * p[j] < N; j++){
            prime[i * p[j]] = false;
            if(i % p[j] == 0) break;
        }
    }
}

int main()
{
   init();
   int n;
   while(scanf("%d",&n)==1)
   {
      int sum=0;
      for(int i=0;i<tot;i++)
      {
         if(p[i]<=n)
            sum++;
         else break;
      }
      cout<<sum<<endl;
   }
   return 0;
}

C++: #include <cstdio>
#include <algorithm>

using namespace std;

const int a[] = {1, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 121, 127, 131, 137, 139, 143, 149, 151, 157, 163, 167, 169, 173, 179, 181, 187, 191, 193, 197, 199, 209};

int func(int v)
{
	int b = v / 210;
	int c = -1;

	int left=0, right=48;
	do{
		int mid = (left+right)/2;
		if(a[mid] == v-b*210){
			c = mid;
			break;
		}else if(a[mid] < v-b*210)
			left = mid + 1;
		else
			right = mid - 1;
	}while(left<=right);

	return c == -1 ? -1 : b*48 + c;
}

int main(void)
{
	unsigned char* eratos = new unsigned char[28572000];
	fill(eratos, eratos+28572000, 0);
	eratos[0] = 1;

	int cnt = 4;
	int i, j, k, n;
	scanf("%d", &n);
	if(n==1) cnt = 0;
	else if(n==2) cnt = 1;
	else if(n<=4) cnt = 2;
	else if(n<=6) cnt = 3;
	else{
		for(i=0; i*210<n; ++i){
			for(j=0; j<48; ++j){
				int v = i*210 + a[j];
				int pos;
				if(v>n)
					break;
				pos = func(v);
				if(!((eratos[pos/8]>>(pos%8))&1)){
					++cnt;
					for(k=v*2; k<=n; k+=v){
						int p = func(k);
						if(p != -1)
							eratos[p/8] |= 1<<(p%8); 
					}
				}
			}
		}
	}

	printf("%d\n", cnt);
	delete[] eratos;

	return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int sum=0;
		for(int i=2;i<=n;i++){
			for(int j=2;j<=sqrt(i);j++){
				if(i%j==0){
					goto loop;
				}
			}
			sum++;
			loop:;
		}
		cout<<sum<<endl;
	}
	return 0;
}

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

int pnum[350000];
int main(){
	int n,data[30] = {0};
	int pcorsole = 0,dcorsole = 0;
	int i,j;
	int root;
	while(scanf("%d",&n) != EOF){
		for(i = 2;i <= n;i++){
			root = (int)sqrt((double)i);
			for(j = 0;j < pcorsole && pnum[j] < root;j++){
				if(i%pnum[j] == 0)
					break;
			}
			if(j == pcorsole || pnum[j] >= root){
				pnum[pcorsole] = i;
				pcorsole++;
				data[dcorsole]++;
			}
		}
		dcorsole++;
	}
	for(i = 0;i <= dcorsole;i++){
		printf("%d\n",data[i]);
	}
	return 0;
}

C++: #include<iostream>
main(){
	int i,j,n,p[1000000];
	std::cin>>n;
	for(i=2;i<=n;i++)
		p[i]=1;
	for(i=2;i<n;i++)
		for(j=2;i*j<=n;j++)
			p[i*j]=0;
	j=0;
	for(i=2;i<n;i++)
		j+=p[i];
	std::cout<<j<<std::endl;
}

C++: #include <iostream>

using namespace std;

int main(){
	int n=0,m=0,o=0,f=0,c=0;

	while(cin>>n){
		c=0;

	for(o=2;o<=n;o++)
	{	f=0;
		for(m=2;m<o;m++){
			if(o%m == 0){f++;}

		};
		if(f==0){c++;};

	};
	cout<<c<<endl;
	};
 return 0;

}