Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		input := nextInt()
		fmt.Println(IsPrime(input))
	}
}

func IsPrime(num int) int {
	eratos := make([]bool, num+1)
	c := 0
	for i := 2; i < len(eratos); i++ {
		if eratos[i] == false {
			c++
			eratosCalc(i, eratos)
		}
	}
	return c
}

func eratosCalc(primeNum int, eratos []bool) {
	for i := primeNum * primeNum; i < len(eratos); i += primeNum {
		eratos[i] = true
	}
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <iostream>

int main(){
	int n,d=0;
	
	while(std::cin>>n){
		int N=n;
		for(int a;a<=n;a++){
			for(int b;b<n;b++){
				int c=a/b;
				if(a==c*b){
					d=1;
				}
			}
			if(d==1){
				d=0;
				N--;
			}
		}
		std::cout<<N<<std::endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define Max 1000005
bool vis[Max];
int prime[Max],cnt;
void print_prime()
{
    memset (vis,false,sizeof (vis));
    for (long long i=2;i<=sqrt(Max);i++)
        if (!vis[i])
        for (long long j=i*i;j<=Max;j+=i)
        vis[j]=true;
    for (long long i=2;i<=Max;i++)
        if (!vis[i])
        prime[cnt++]=i;
}
int main()
{
    print_prime();
    int n;
    while (scanf("%d",&n)!=EOF) {
        int i=0;
        while (prime[i]<=n) {
            i++;
        }
        printf("%d\n",i);
    }
    return 0;
}

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

bool isChecked[1000010];
vector <int> prime;

int CountPrimeNum(int max) {
	
	int count = 0;
	for (int i = 0; i < 1000000; i++) {
		if (prime[i] > max) break;
		count++;
	}	
	return count;
}


int main() {
	for(int i = 0; i < 1000000; i++) {
		isChecked[i] = false;
	}
	
	isChecked[0] = true;
	isChecked[1] = true;
	
	for (int i = 2; i < 1000000; i++) {
		if(isChecked[i]) continue;
		
		prime.push_back(i);
		
		for (int j = 1;j * i < 1000000;j++) {
			isChecked[i*j] = true;
		}
	}
	
	int n;
	while(cin >> n) {
		cout << CountPrimeNum(n) << endl;
	}
	
	return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX_N 999999 + 16
 
int  prime[MAX_N];			
bool is_prime[MAX_N + 1];	
int sieve(const int& n)
{
	int p = 0;
	fill(is_prime, is_prime + n + 1, 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 argc, char *argv[])
{
	int n;
	while (cin >> n)
	{
		cout << sieve(n) << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>

#define REP(i,n) for(long (i)=0;(i)<(n);(i)++)
#define FOR(i,a,b) for(long (i)=(a);(i)<(b);(i)++)
#define RREP(i,a) for(long (i)=(a)-1;(i)>=0;(i)--)
#define FORR(i,a,b) for(long (i)=(a)-1;(i)>=(b);(i)--)
#define MOD 1000000007
#define PI acos(-1.0)
#define DEBUG(C) cout<<C<<endl;
#define PII pair<int,int>
#define PDD pair<double,double>
#define PLL pair<long,long>
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define RSORT(a) sort((a).begin(),(a).end(),greater<int>())
#define MP(a,b) make_pair(a,b)
#define FORE(a,b) for(auto &&a:b)

typedef long long LL;
typedef unsigned long long ULL;

using namespace std;

template<typename T>
list<T> SieveOfEratosthenes(T a){
    list<T> num,res;
    for(T i=2;i<=a;i++) num.push_back(i);
    for(auto i=num.begin();(*i)*(*i)<=a;){
        T n=*i; res.push_back(*i); i++;
        for(auto j=num.begin();j!=num.end();){
            if(*j%n==0) j=num.erase(j);
            else j++;
        }
    }
    for(auto i=num.begin();i!=num.end();i++) res.push_back(*i);
    return res;
}

int main(void){
	int n;
	while(cin>>n) cout<<SieveOfEratosthenes(n).size()<<endl;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(n) rep(i,n)
#define all(n)
const int MAXN = 1000000;

int p[MAXN];

int main()
{
    p[0] = p[1] = 1;
    REP(MAXN)if(!p[i])for(int j=i*2;j<MAXN;j+=i)p[j]=1;

    int n, ans;
    while(cin >> n)
    {
        ans = 0;
        REP(n + 1) ans += !p[i];
        cout << ans << endl;
    }

    return 0;
}

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

using namespace std;

int sosuu(int n) {
    vector< int > list;
    for (int i = 2; i <= n; i++) {
        list.push_back(i);
    }
    int count = 0;
    int p;
    while (true) {
        p = list[count];
        count++;
        for (int i = 0; i < list.size(); i++) {
            if (list[i] % p == 0 && list[i] != p) {
                list.erase(list.begin() + i);
                i--;
            }
        }
        if (list.size() > sqrt(n)) break;
    }
    // for (int i = 0; i < list.size(); i++) {
    //     cout << list[i] << " ";
    // }
    // cout << endl;
    return list.size();
}

int main() {
    int a;
    while (!cin.eof()) {
        cin >> a;
        if (std::cin.fail()) break;
        cout << sosuu(a) << endl;
    }

    return 0;
}

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

int main()
{
	int n, i, j, k=1, wareru=0;
	int sosu[500000];
	sosu[0] = 2;
	for (i = 3; i < 1000000; i += 2)
	{
		wareru = 0;
		for (j = 3; j <= sqrt(i*1.0); j += 2)
		{
			if (i%j == 0)
			{
				wareru = 1;
				break;
			}
		}
		if (wareru == 0)
		{
			sosu[k++] = i;
		}
	}

	while (scanf("%d", &n) != EOF)
	{
		for (i = 0; (sosu[i] <= n) && (sosu[i] != NULL); i++);
		printf("%d\n", i);
	}
	return 0;
}

C++: #include<stdio.h>
int main(void){
   int s[10000], l, m, n, i, k, sum;
   sum = 0;
   for ( i = 1; i <= 1000000; i++ ) {
      s[i] = 0;
   }
   for ( k = 2; k <= 1000000; k++ ){
      if (s[k] == 0) {
         for ( l = 2; l <= 100000 / k; l++ ) {
            s[k * l] = 1;
         }
      }
   }
   while(scanf("%d", &n) != EOF){
      for(i = 1; i <= n; i++){
         if(s[i] == 0){
            sum++;
         }
      }
   printf("%d", sum);
   }
   return 0;
}

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

using namespace std;

int main(){
  int n, i, j, isFound, count;

  while(cin >> n){
    for(i=3, count=1; i<=n; i+=2){
      for(j=3, isFound=0; j<=sqrt(i); j+=2){
	if(i%j == 0){
	  isFound = 1;
	  break;
	}
      }
      if(isFound == 0) count++;
    }
    cout << count << endl;
  }

  return 0;
}

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

std::vector<bool> primes(1000000, true);

void sieve() {
  primes[0] = false;
  primes[1] = false;
  for (int i = 2; i < primes.size(); ++i) {
    if (!primes[i]) { continue; }
    for (int j = 2, m = i * j; m < primes.size(); m = i * ++j) {
      primes[m] = false;
    }
  }
}

int main() {
  sieve();

  int n;
  while (true) {
    if (scanf("%d", &n) != 1) { break; }
    int count = 0;
    for (int i = 0; i <= n; ++i) { if (primes[i]) { ++count; } }
    printf("%d\n", count);
  }

  return 0;
}

C++: #include <iostream>
#include <cmath>
#include <cstdio>
using namespace std;
int whether(int num);
int count(int num);

int main(){
    int n;
    
    while(~scanf("%d",&n)){
        cout <<count(n)<<endl;
    }
    
    return 0;
}

int whether(int num){
    int s=sqrt(num);
    int i;
    
    for(i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    
    return 1;
}

int count(int num){
    int a=1;
    if(num<2){ return 0; }
    if(num==2){ return 1; }
    for(int i=3; i<=num; i+=2){
        if(whether(i)){ a+=1; }
    }
    
    return a;
}