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 <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V+1],sum[MAX_V+2]={0};
int main(){
  int n;
  for(int i = 2;i <= MAX_V;i++){
    prime[i] = 1;
  }
  for(int i = 2;i * i <= MAX_V;i++){
    if(prime[i]){
      for(int k = 2* i;k <= MAX_V;k += i)
      prime[k]=0;
    }
  }
  for(int i = 2;i < MAX_V;i++){
    sum[i] +=sum[i-1]+prime[i];
  }
  while(scanf("%d",&n)!=EOF){
    printf("%d\n",sum[n]);
  }
  return 0;
}

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

bool isPrime(unsigned int n);

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

    return 0;
}

bool isPrime(unsigned int n)
{
    if( n==0 || n==1 ) return false;
    if( n==2 ) return true;
    if(!(n%2)) return false;
    
    int rn = static_cast<int>(sqrt(n));
    
    bool flag = true;
    for(int i=3; i<=rn; i+=2){
        if(!(n%i)){
            flag = false;
            break;
                }
    }
    return flag;
}

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

using namespace std;
bool IsPrime[1000000];
vector<int> Prime;

void calc()
{
	for(int i = 0; i < 1000000; ++i)
	{
		IsPrime[i] = true;
	}
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	calc();
	int n;
	cin >> n;
	int count = 0;
	int a = Prime.size() - 1;
	while(Prime[count] <= n)
	{
		if(count >= a)
		{
			break;
		}
		count++;
	}
	cout << count << endl;
}

int main()
{
	solve();
	return(0);
}

C++: #include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define MAX      10000010
bool prime[MAX];
void seive(){
memset(prime,true,sizeof(prime));
prime[0]=prime[1]=false;
for(int p=2;p*p<=MAX;p++){
       if(prime[p]){
    for(int i=p*p;i<=MAX;i+=p){
       prime[i]=false;
    }
}

}
}
int main(){
seive();
ll n;
int c=0;
while(cin>>n){
 for(int i=2;i<=n;i++){
   if(prime[i]){
    c++;
   }
 }
 cout<<c<<endl;
 c=0;
}

}

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

bool prime(int m){
	if(m < 2)return false;
	if(m == 2)return true;
	if(m%2 == 0)return false;
	for(int i = 3; i*i <= m; i += 2){
		if(m%i == 0)return false;
	}
		return true;
}

int main(){
	int n;
	
	while(cin >> n){
		int a=0;
		for(int i = 1; i <= n; ++i){
			if(prime(i))++a;
	}
		cout << a << '\n';
	}
}

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;
	for (int i = 2; i*i<= MAX; i++){
		if (!vis[i]){
			prime[i] = 1;
			for (int j = i *i; j <= MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;
			}
		}
	}
	
	int n, m;
	while (cin >> n>>m){
		if (n==m) cout <<0 << endl;
		else {

		}
	}
	return 0;
}

C++: j,a['   '],s;main(i){for(;++i<1e6;){if(!a[i])for(j=i;j<1e6;)a[j+=i]=1;a[i]=s+=!a[i];}for(;~scanf("%d",&i);printf("%d\n",a[i]));}

C++: #include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

C++: #include<iostream>
using namespace std;
int main(){
	long long int N,count=0;
	while(cin >> N){
		count = 0;
		if(N<0)	break;
	for(int x=2;x<=N;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count++;
	}
	cout << count << endl;
	}
	return 0;
}

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

int sosu(long x){
	int a=1;
	long b,c,d;
	d=sqrt(x);
	for(b=3;b<=d;b=b+2){
		c=x%b;
		if(c==0){
			a=0;
			break;
		}
	}
	return (a);
}

int main(void){
	int y,z;
	long i,j,k,n;
	long f[168];
	j=0;
	for(i=3;i<=10000;i=i+2){
		if(sosu(i) == 1){
			f[j]=i;
			j++;
			if(j==168)break;
		}
	}
	for(i=0;i<168;i++){
//		printf("%ld\n",f[i]);
	}
	while(scanf("%d",&n) != EOF){
		z=1;
		for(i=3;i<=n;i=i+2){
			y=1;
			for(j=0;j<168;j++){
				if(i==f[j]) break;
				else k=i%f[j];
				if(k==0){
					y=0;
					break;
				}
			}
			z=z+y;
		} 
		if(n==1) printf("0\n");
		else printf("%d\n",z);
	}
	return 0;
}

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

#define N 1000000

int main() {
    int n;
    bool prime[N+1];
    int count[N];
    for(int i=2; i<N; i++){
        prime[i] = true;
    }
    for(int i=2; i<N; i++){
        if(prime[i]){
            count[i] = count[i-1]+1;
            if(i<1000){
                for(int j=i*2; j<N; j+=i){
                    prime[j] = false;
                }
            }
        }else{
            count[i] = count[i-1];
        }
    }
    
    while(cin >> n){
        cout << count[n] << endl;
    }
    return 0;
}

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

int main(){
	int cnt, x, n, i, j;
	bool flg;
	double rootx;
	int rootintx;
	while(cin>>n){
		cnt=0;
		if(n>=2)cnt++;
		for(x=3;x<=n;x+=2){
			flg = true;
			if(x==2){
				cnt++;
				continue;
			}
			if(x<2 || !(x%2)){
				continue;
			}
			rootx = sqrt(x);
			rootx = ceil(rootx);
			rootintx = int(rootx);
			for(j=2;j<=rootintx;j++){
				if(!(x%j)){
					flg=false;
					break;
				}
			}
			if(flg)cnt++;
		}
		cout<<cnt<<endl;;
	}
	return 0;
}

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

using namespace std;

int main(void){
	int num = 0;
	vector<int> vec;
	while (cin >> num){
		int count = 0;
		bool hantei = true;
		for (int i=2; i<num; ++i){
			for (int j=2; j<i; ++j){
				if ((i%j) == 0){
					hantei = false;
					break;
				}
			}
			if (hantei == true){
				++count;
			}
		}
		vec.push_back(count);
	}
	vector<int>::iterator it = vec.begin();
	while(it != vec.end()){
		cout << *it << endl;
		++it;
	}
	return 0;
}

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/2;m++){
			if(o%m == 0){f++;}

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

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

}