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

using namespace std;
int c = 0;
int i = 1;
unsigned long long a = 0;
unsigned long long b = 0;
unsigned long long sosuu[100000] = { 0 };
int pattara = 0;

int sub(int c) {

	
	
	
	for (int i = 2; i<=c; i++){
		
		for (int q = 1; q <= sqrt(i); q++) {
			sosuu[pattara] = i;
			if (sosuu[pattara] % 2 == 0 && sosuu[pattara]!= 2) {
				break;
			}
			if (sosuu[pattara] % q == 0) {
				b += 1;
			}

		}

		if (b == 1) {
			
			pattara++;
			
		}
		b = 0;
		
	}

	
	return 0;
}


int main(){
	while (scanf("%d", &c) != EOF){

		sub(c);
		cout << pattara << endl;
		pattara = 0;
		
	}

	return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 int arr[1000005]={0};
 
 bool isPrime(int x)
 {
   for(int i=2;i<=(int)(sqrt(x));i++) 
   {
     if(x%i==0) return false;        
   }    
   return true;
 }
 
 int main()
 {
   int n;
   while(cin>>n)
   {
      if(n==1) cout<<"0"<<endl;
      else if(n==2) cout<<"1"<<endl;
      else if(arr[n]!=0) cout<<arr[n]<<endl;
      else
      {
        int count=1;
        for(int i=3;i<=n;i++)
        { 
          if(isPrime(i))
          { 
            count++;
            arr[i]=count;
          }
          else arr[i]=count;
        }
        cout<<count<<endl;
      } 
   }
   //while(1);      
   return 0;    
 }

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

int main(){
    long long n, i, j, yaku, count;
    while (~scanf("%lld",&n)) {
        count=1;
        if (n==1) {
            printf("%d\n",0);
        }
        else if (n==2){
            printf("%d\n",1);
        }
        else{
            for (i=3; i<=n; i+=2) {
                yaku=0;
                for (j=3; j<=sqrt(i); j+=2) {
                    if (i%j == 0) {
                        yaku=1;
                        break;
                    }
                }
                if (yaku == 0) {
                    count++;
                }
            }
            printf("%lld\n",count);
        }
    }
    
    
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	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 <iostream>
#include <cmath>
bool prime[1000001];
using namespace std;
int main(){
	int i,j,n;

	for (i = 3; i <= 1000000; i += 2){
		prime[i] = true;
	}
	prime[2] = true;

	for (i = 3; i <= 1000; i += 2){
		if (prime[i] == 1){
			for (j = 3; j <= 1000000 / i; j += 2){
				prime[i * j] = false;
			}
		}
	}
	while(cin >> n && n){
		int count = 0;
		for(i=2;i<=n;i++){
			if(prime[i] == true) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include<bits//stdc++.h>
using namespace std;
int main(){
	int a[1000500];
	a[0]=1;
	a[1]=1;
	for(int i=2;i*i<1000500;i++){
		if(a[i]==0){
			for(int j=i*2;j<1000500;j+=i){
				a[j]=1;
			}
		}
	}
	int b;
	while(cin>>b){
		int c=0;
		for(int i=0;i<=b;i++){
			if(a[i]==0) c++;
		}
		cout<<c<<endl;
	}
}

C++: #include<iostream>
const int MAX_N=1000000;
using namespace std;
bool value[MAX_N];
int main(){
	int n;
	while(cin>>n){
	  int count=0;
	for(int i=1;i<=n;++i){
	 value[i]=true;
	}
	for(int i=2;i<=n;++i){
		if(value[i]){
		for(int j=i+1;j<=n;++j){
		    if(j%i==0)
		      value[j]=false;
		  }
		}
	}
	for(int i=2;i<=n;++i){
	   if(value[i])
		   ++count;
	}
	cout<<count<<endl;
	}
return 0;
}

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

Int pn[1000002];

int main(){
int n, Count;
con.tie(0);
while(scanf("%d",&n)!=EOF){
Count=0;
memset(pn,0,n);
pn[0]=pn[1]=1;
for(int i=0;i<=n;i++) if(!pn[i]) for(int j=0;i*j<=n;j++) pn[i*j]=1;
Count=count(pn,pn+n,0);
count<<Count<<endl;
}
return 0;
}

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

int main() {
	const int MAX_V = 100000;
	int prime[MAX_V+1];
	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;
			}
		}
	}
	scanf("%d", &v);
	while (v != 0){
		int count = 0;
		for(i=0;i<=v;i++){
			int isprime = prime[i];
			if(isprime) count ++;
		}
		printf("%d\n",count);
		scanf("%d", &v);
	}
	return 0;
}

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

int main() {
	int n,i,j,a=0,b=0;
	while (cin >> n) {
		if(n>=9) {
			for (i = 9; i <= n; i++) {
				a=0;
				for (j = 3; j < i; j++) {
					if (i%j == 0) {
						a++;
						b += a;
						break;
					}
					j++;
				}
				i++;
			}
		}
		if (n == 2)cout << "1" << endl;
		else if (n == 1)cout << "0" << endl;
		else if (n == 3)cout << "2" << endl;
		else if (n == 5) cout << "3" << endl;
		else if (n == 7)cout << "4" << endl;
		else if (n % 2 == 0) cout << n / 2 - b << endl;
		else cout << (n + 1) / 2 - b  << endl;
		b = 0;
	}
	return 0;
}

C++: #include <iostream>

auto is_prime (int x) -> bool
{
    for (auto i = 2; i * i <= x; ++ i)
    {
        if (x % i == 0)
        {
            return false;
        }
    }
    return true;
}

auto main () -> int
{
    int prime_num [1000000] = {0 , 0 , 1};
    for (auto i = 3; i < 1000000; ++ i)
    {
        prime_num [i] = prime_num [i - 1] + is_prime (i);
    }

    int n;
    while (std::cin >> n)
    {
        std::cout << prime_num [n] << std::endl;
    }
}

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

const int C = (int)1e7+10;

bool isprime[C];
int prime[C];

void init() {
  fill(isprime, isprime+C, true);
  isprime[0] = isprime[1] = false;
  for (auto i=2; i<C; i++) {
    if (isprime[i]) {
      for (auto j=2; i*j<C; j++) {
	isprime[i*j] = false;
      }
    }
  }
  prime[0] = 0;
  for(auto i=1; i<C; i++) {
    prime[i] = ((isprime[i]) ? prime[i-1]+1 : prime[i-1]);
  }
}

int main() {
  init();
  int n;
  while (cin >> n) {
    cout << prime[n] << endl;
  } 
}

C++: 
#include <iostream>
#include <algorithm>
#include <string.h>
#include <math.h>
#include <vector>

using namespace std;

#define pb push_back
#define mp make_pair
#define ll long long
#define ull unsigned ll
#define db double
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define PII pair<int, int>

const int N=1000000;
bool p[N+10];
vector<int> primes;

int main()
{
    for (int i=2;i<=N;i++) {
        if (!p[i]) primes.pb(i);
        for (int j=0;j<primes.size()&&primes[j]*i<=N;j++) {
            p[primes[j]*i]=1;
            if (i%primes[j]==0) break;
        }
    }
    int n;
    while (~scanf("%d",&n)) {
        int ans=upper_bound(primes.begin(),primes.end(),n)-primes.begin();
        printf("%d\n",ans);
    }
}