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<vector>
using namespace std;

int main()
{
	vector<int> pcount;
	int prime[10000];
	int j, k, x, num,count=0;
	while (cin >> num){
		prime[0] += 2;
		x = 1;
		k = 1;
		while (prime[k-1] <= num)
		{
			x += 2;
			j = 0;
			while (j < k && x % prime[j] != 0)j++;
			if (j == k)
			{
				prime[k++];
				count++;
			}
		}
		pcount.push_back(count);
		count = 0;
	}
	for (int i = 0; i < pcount.size(); i++)
	{
		cout << pcount[i] << endl;
	}
	return 0;
}

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

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

int solve(int x){
    int m = 0;
    for(int i=0;i<=x;i++){
        if(isprime(i)){
            m++;
        }
    }
    return m;
}
int main(){
    int n;
    cin >> n;
    cout << solve(n) << endl;
    return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <set>
#include <cstring>
#include <cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for (int i = (int)(k); i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n)-1; i >= 0; i--)
#define rREP(i, k, n) for (int i = (int)(n)-1; i >= k; i--)

#define debug(x) cerr<<#x<<": "<<x<<'\n'

#define fi first
#define se second

#define vi vector<int>
#define pb push_back
#define mp make_pair

#define pcnt __builtin_popcount

typedef long long ll;

const int inf = 100100100;
const int MOD = 998244353;
const double EPS = 1e-9;

bool s[1000000] = {};
int sosu[1000000] = {};
void erast(){
  memset(s,1,sizeof(s));
  s[1] = false;
  s[0] = false;
  REP(i,2,1000){
    if(s[i]){
      REP(j,2,1000000){
        if(i*j>=1000000) break;
        s[i*j] = false;
      }
    }
  }
  REP(i,2,1000000) sosu[i] = sosu[i-1]+s[i];
}

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    erast();
    int n;
    while(cin >> n,n){
      cout << sosu[n] << endl;
    }
    return 0;
}

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

using namespace std;
const int N=999999;
bool isprime[N+1];
int sum[N+1];

int main()
{
    memset(isprime,true,sizeof(isprime));
    for(int i=2;i<N/2;i++)
        for(int j=2*i;j<N;j+=i)
            if(isprime[i]) isprime[j]=false;
    isprime[0]=isprime[1]=false;
    memset(sum,0,sizeof(sum));
    for(int i=2;i<N;i++)
    sum[i]=sum[i-1]+isprime[i];

    int n;
    while(cin>>n)
    {
        cout<<sum[n]<<endl;
    }
    return 0;
}

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

using namespace std;

int SUUZI[1000000];

int a=0,b,d,f,n,c=0;
double buffer;

int main(){

	for(d=0;d<1000000;d++){SUUZI[d]=1;};
	
		for(a=3;a<1000000;a++){
			buffer=a;
				for(b=2;1;b++){
					if(a%b==0){SUUZI[a]=0;break;};
					if(b>sqrt(buffer)){SUUZI[a]=1;break;};
				};
};


while(cin>>n){
	c=0;
for(d=0;d<=n;d++){c+=SUUZI[d];};

cout<<c-2<<endl;

};
return 0;

}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-8;
typedef long long ll;

const int SIZE = 1000001;
bool is_prime[1000001];
vector<int> primes;
int main()
{
	fill(is_prime, is_prime+SIZE, true);
	for (int i = 2; i < SIZE; ++i)
	{
		if (is_prime[i])
		{
			for (int j = 2*i; j < SIZE; j += i)
				is_prime[j] = false;
			primes.push_back(i);
		}
	}

	int n;
	while (scanf("%d", &n) != EOF)
		printf("%d\n", upper_bound(primes.begin(), primes.end(), n) - primes.begin() - 1);

	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

constexpr int N = 999999;
vector<bool> primes( N+1, true );

void make_table() {
	primes[0] = false;
	primes[1] = false;

	int nr = (int)sqrt( N );
	for( int i = 2; i <= nr; ++i ) {
		if( primes[i] ) {
			for( int j = i+i; j <= N; j += i ) {
				primes[j] = false;
			}
		}
	}
}

int main() {
	ios_base::sync_with_stdio( false );

	make_table();

	int n;
	while( cin >> n ) {
		cout << count( primes.begin()+1, primes.begin()+1 + n, true ) << endl;
	}
}

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

C++: #include	<stdio.h>

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

int main(int argc, char** argv){
	
	int search, counter;
	
	while((scanf("%d", &search)) != EOF){
		counter = 0;
		for(int i = 2; i <= search; i++){
			counter += isPrimeNumber(i) ? 1 : 0;		
		}
		printf("%d\n", counter);
	}
	
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
ll max_n = 1e6+4; 
void solve(){
    ll p = 0;
    ll Prime[n];
    ll isPrime[n+1];
    for(int i=0 ; i<=n ; i++){
        isPrime[i] = true;
    }
    isPrime[0] = isPrime[1] = 0;
    for(int i=2 ; i<=n ; i++){
        if(isPrime[i]){
            p++;
            for(int j=2*i ; j<=n ; j+=i){
                isPrime[j] = false;
            }
        }
    }
    cout << p << endl;
}

int main(){
    while (cin >> n, cin.eof() != true){
        solve();
    }
    return 0;
}

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, i;
	int a[10] = {0, 9592, 17984, 25997, 33860, 41538, 49098, 56543, 63951, 71274};
	while(cin >> n){
		i = 0;
		c = 0;
		for(int j = 900000; j >= 100000; j -= 100000){
			if(j < n){
				i = j+1;
				c = a[j/100000];
				break;
			}
		}
		
		for(; i <= n; i++){
			if(prime(i) == 1){
				c++;
			}
		}
		
		cout << c << endl;
	}
	
	return 0;
}

C++: #include<stdio.h>
#define MAX 1000010

int main(){
	bool prime[MAX];
	prime[0]=prime[1]=0;
	for(int i=0;i<MAX;i++){
		prime[i]=1;
	}
	prime[0]=prime[1]=0;
	for(int i=2;i<MAX;i++){
		if(prime[i]==1){
			for(int j=2;i*j<MAX;j++){
				prime[i*j]=0;
			}
		}
	}
	int prime_under_num[MAX];
	prime_under_num[0]=0;
	for(int i=1;i<MAX;i++){
		prime_under_num[i]=prime_under_num[i-1]+prime[i];
	}
	
	int n;
	while((scanf("%d",&n))!=EOF){
		printf("%d",prime_under_num[n]);
	}
	
	
}

C++: #include <stdio.h>

int main(){
	int sosuu[1000000] = { 2, 3, 5 }, i,x,y=3,n;

	for (i = 3; i < 1000000; i+=2){
		for (x = 0; x < y;x++){
			if (i % sosuu[x] == 0){ break; }
			if (x+1 == y){ sosuu[y] = i, y++; }
		}
	}

	while (scanf("%d",&n)!= EOF){
		for (i = 0; i < y; i++){
			if (sosuu[i] < n + 1)break;
		}
	}
	return 0;
}