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 <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(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<stdio.h>
#include<math.h>
#include<string.h>

#define M 1000001

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

C++: #include <iostream>
using namespace System;
using namespace std;
const int MAX_N =1000000;
int main(){
	bool sosu[MAX_N]={};//false:sosu
	for(int i=2;i<MAX_N;i++){
		if(!sosu[i]){
			for(int j=2;j*i<MAX_N;j++){
				sosu[j*i]=true;
			}
		}
	}
	for(int n;cin>>n;){
		int ans=0;
		for(int i=2;i<=n;i++){
			if(!sosu[i])ans++;
		}
		cout<<ans<<endl;
	}
    return 0;
}

C++: 

 #include<iostream>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

//Nayeem Shahriar Joy ,Applied Physics And Electronic Engineering , University of Rajshahi.


int main(){

    bool prime[1000002];

    memset(prime,true,sizeof(prime));

    prime[0]=false;

    prime[1]=false;

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

 int n;

 while(cin>>n)

 {
     int count=0;

     for(int i=0;i<=n;i++)

     {
         if(prime[i]==true)
         {
             count++;
         }
     }
     cout<<count<<endl;
 }

    return 0;
}

C++: #include <iostream>
#include <cstring>
using namespace std;
#define MAX_SIZE 1000100
#define N 999999
int preme[MAX_SIZE];


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

int main(int argc, char *argv[]) {
	memset(preme, 0, sizeof(preme));
	int index = 0;
	for(int i = 1; i <= N; i += 2)
		preme[i] = 1;
	
	for(int i = 3; i <= 999999; i += 2) {
		if(preme[i]) {
			for(int j = i + i; j <= 999999; j += i)
				preme[j] = 0;
		}
			
	}
	
	int n;
	while(cin >> n) {
		int count = 0;
		for(int i = 1; i <= n; i++)
			if(preme[i])
				count++;
		cout << count << endl;
	}
		
}

C++: #include <bits/stdc++.h>

#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) REP (i, 0, n)
#define mset(a, n) memset(a, n, sizeof(a))

using namespace std;

const int MAX_N = 1000000;
bool prime[MAX_N];
void eratos() {
	rep(i, MAX_N) prime[i] = true;
	prime[0] = false;
	prime[1] = false;
	REP(i, 2, sqrt(MAX_N)) {
		if (prime[i]) {
			for (int j = 0; i * (j + 2) < MAX_N; ++j) {
				prime[i * (j + 2)] = false;
			}
		}
	}
}

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

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

bool isprime(int x) {
	if (x == 2)
		return true;
	if ((x < 2) || (x % 2 == 0)) {
		return false;
	}
	int i = 3;
	while (i == sqrt(x)) {
		if (x%i == 0)
			return false;
		i = i + 2;
	}
	return true;
}

int main()
{
	
	int n;
	while (cin >> n) {
		int C = 0;
		for (int i = 2; i <= n; i++) {
			if (isprime(i) == true)
				C++;
		}
		cout << C<<endl;
	}
	return 0;
}

C++: #include<stdio.h>

int s[100000] = {0};

int main(){
	int a,b,c,d,e;
	int temp;
	int cont = 0;
	
	while(scanf("%d",&a) != EOF){
		/*
		for(int i = 0; i < a; i++){
			s[i] = 1;
		}
		*/
		
		cont = 0;
		
		s[0] = 1;
		s[1] = 1;
		
		for(temp = 2; temp < a; temp++){
			if(s[temp] == 0){
				for(b=temp; b < a; b+= temp){
					if(b == temp){
						s[b] = 0;
					}
					else{
						s[b] = 1;
					}
				}
			}
		}
		
		for(c = 0; c < a; c++){
			if(s[c] == 0){
				
	//		printf("%d\n",c);
				cont++;
			}
		}
		
		printf("%d\n",cont);
	}
}

C++: #include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  bitset<1'000'000> bs;
  bs.set();
  bs[0] = bs[1] = false;
  for (int p = 2; p <= 1000; ++p) {
    for (int i = p * p; i < 1'000'000; i += p) bs[i] = false;
  }
  string s;
  while (getline(cin, s)) {
    int n = stoi(s);
    int res = 0;
    for (int i = 0; i <= n; ++i) res += bs[i];
    cout << res << '\n';
  }
}

C++: #include <cstdio>
#define max_n 999999
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }
    int n;
    while(scanf("%d",&n)!=EOF){
        printf("%d\n",n);
        int ans = 0;
        for(int i =0; i<max_n; i++){
            ans = 0;
            if(prime[i]>n){
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

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

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

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

int Eratosthenes(int N){

  int count=0;
  bool* IsPrime = new bool[N];
  IsPrime[0] = false;
  IsPrime[1] = false;
  for(int i=2; i<=N;i++){
    IsPrime[i] = true;
  }
  for(int i=2; i*i<=N;i++){
    if(IsPrime[i]){
      for(int j=2*i; j<=N; j+=i)
        IsPrime[j] = false;
      }
  }
  for(int i=0; i<=N;i++)
    if(IsPrime[i]) count++;

  delete[] IsPrime;
  return count;
}

int main(void)
{
    int N[30]={};
    int count=0;
    int i=0;
    while(1){
      if(scanf("%d",&N[i])!=1)
        break;
      i++;
    }
    i=0;
    while(N[i]>0){
      count=Eratosthenes(N[i]);
      printf("%d\n",count);
      i++;
    }

    return 0;
}

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

bool Prime(int n);

int main(){

  int n;
  int sum;

  while(scanf("%d",&n)!=EOF){
    sum = 0;
    for(int i=3; i<=n; i+=2){
      sum += Prime(i);
    } 
    cout << sum+1 << endl;
  }

  return 0;
}


bool Prime(int n){

  if(n%2==0)
    return false;

  else{
    for(int i=3; i<=sqrt(n); i+=2){
      if(n%i == 0)
	return false;
    }
  }

  return true;
}