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 <stdio.h>
int isprime(int n){
	int i;
	for(i=2;i<n;i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}
int main(){
	int i,n,c;
	while(1){
		if(n == EOF){
			break;
		}
		scanf("%d",&n);
		c=0;
		for(i=2;i<=n;i++){
			if(isprime(i) == 1){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){
    int n;
    vector<int> S;
    double a=sqrt(n);
    while(cin>>n){
        S.push_back(2);
        int ans=0;
        for(int i=3; i<=a; i++){
            int judge=0;
            for(int j=0; j<S.size(); j++){
                if(i%S[j]==0)judge=1;
            }
            if(judge==0){
                ans++;
                S.push_back(i);

            }
        }
        cout<<ans+1<<endl;
        S.clear();
    }
    return 0;
}

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

int main()
{
	bool IsPrime[1000010] = {};
	for (int i = 2; i < 999999; i++)
	{ 
		IsPrime[i] = true;
	}
	for (int i = 2; i*i <= 999999; i++)
	{
		if (IsPrime[i])
		{
			for (int j = i * 2; j <= 999999; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}

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

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

//C

const int MAX_N = 1000000;
int prime[MAX_N];
bool is_prime[MAX_N + 1];

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 (scanf("%d", &n) != EOF)
	{
		int ans = sieve(n);
		printf("%d\n", ans);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<n;i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

ll N;

constexpr ll max_n = 1000006;
bool prime[max_n];

void solve(){
    int cnt=0;
    for(int i=2;i<=N;i++) if(prime[i]) cnt++;
    cout << cnt << endl;
}

int main(){
    rep(i,max_n) prime[i]=true;
    for(int i=2;i<max_n;i++){
        if(!prime[i]) continue;
        for(int j=2;i*j<max_n;j++) prime[i*j] = false;
    }

    while(cin>>N){
        solve();
    }
}

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

C++: 
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    bool a[1000000]={false};
    for(int i=2;i<1000;i++){
        bool t=false;
        for(int j=2;j*j<=i;j++){
            if(i%j==0)
                t=true;
        }
        if(i==2)
            t=false;
        if(t==false){
            for(int j=i*2;j<1000000;j+=i)
                a[j]=true;
            a[i]=false;
        }
    }
    while(cin>>n){
        int count=0;
        for(int i=0;i<=n;i++){
            if(a[i]==false)
                count++;
        }
        cout<<count-2<<endl;
    }
    return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];

void init(){
    int i, k, v;
    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;
            }
        }
    }   
}

int isprime(int n){
    return prime[n];
}

int main(){
    init();
    int num;
    while(scanf("%d", &num) != EOF){
        int count=0;
        for(int i=2; i<=num; i++){
            if(isprime(i)==1)
                count++;
        }
    printf("%d\n", count);
    }
    return 0;
}

C++: #include<stdio.h>
int main(){
	int a,b,c,n;
	c=0;
	scanf("%d",&n);
		for(a=2;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 <cmath>
using namespace std;


int main(){
	int number,cnt=0;
	cin>>number;
	int* arr = new int[number+1];
	for (int i = 1; i <= number; i+=2)
	{
		arr[i-1]=0;
		arr[i]=1;
	}
	for (int i = 3; i < sqrt(number); i+=2)
		if (arr[i])
			for (int j = i+i; j <=number; j+=i)
				arr[j]=0;
	arr[2]=1;arr[1]=0;
	for (int i = 0; i < number; i++)
		if (arr[i])
			++cnt;
	cout<<cnt;
}

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

using namespace std;


int main(){
	const int MAX_NUM=1000000;
	int table[MAX_NUM]={};
	for(int i=2;i<1001;i++){
		if(table[i]==1)continue;
		for(int j=i*2;j<MAX_NUM;j+=i){
			table[j]=1;
		}
	}

	int input;
	while(cin>>input){
		int count=0;
		for(int i=2;i<=input;i++){
			//cout<<"table:"<<i<<"="<<table[i]<<"\n";		
			if(table[i]==0)count++;
		}
		cout<<count<<"\n";
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	bool p[1000000] = { false };
	int n;
	for (int i = 2; i <1000000; i++){
			for (int i2 = 2; i*i2 <= n; i2++){
				p[i*i2] = true;
			}
		}
		p[2] = false;
		p[3] = false;
	while (cin >> n){
		
		
		int c = 0;
		for (int i = 2; i <= n; i++){
			if (!p[i])c++;
		}
		cout << c << endl;
	}
}

C++: #include<cstdio>
using namespace std;
const int N = 1000000;

int main(){

  int IsPrime[N];
  IsPrime[0] = 1;
  IsPrime[1] = 1;
  for(int i=2; i*i<=N;i++){
    if(IsPrime[i]==0){
      for(int j=2*i; j<=N; j+=i)
        IsPrime[j] = 1;
      }
  }
  int max;
  while(~scanf("%d",&max)){
    int count=0;
    for(int i=1; i<max+1; i++)
      if(IsPrime[i]==0) count++;
    printf("%d\n",count);
  }
}