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

bool IsPrime(int m){
    if(m==1){
        return(0);
    }else if(m==2){
        return(1);
    }else if(m%2==0){
        return(0);
    }else{
        for(int i=3;i*i<=m;i+=2){
            if(m%i==0)return(0);
        }
        return(1);
    }
}

int main(){
    int n;
    int r[30];
    for(int i=0;i<30;i++){
        r[i]=0;
    }
    int j=0;
    while(cin>>n){
        for(int i=1;i<=n;i++){
            if(IsPrime(i))r[j]++;
        }
        cout<<r[j]<<endl;
        j++;
    }
    return(0);
}

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

using namespace std;

int main(){
        int i=2,j=2,n,count=0;
        while(scanf("%d",&n) != EOF){
                while(i <= n){
                        while(j <= i){
                                if(i%j == 0) break;
                                j++;
                        }
                        if(j == i){
                                count++;
                        }
                        i++;
                        j = 2;
                }
                i = 2;
                cout << count <<endl;
                count = 0;
        }
        return 0;
}

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

template<int N>
class primes
{
public:
    constexpr static auto NN = static_cast<int>(std::sqrt(N));

public:
    constexpr primes()
    {
        for( int i=2; i<N; ++i )
            not_primes[i] = false;

        for( int i=2; i<NN; ++i ) {
            if ( not_primes[i] ) continue;

            for( int j=i*i; j<N; j+=i ) {
                not_primes[j] = true;
            }
        }
    }

    auto count(int i) const
    {
        return std::count(std::begin(not_primes), std::begin(not_primes) + i + 1, false);
    }

private:
    bool not_primes[N] = {true, true};
};

int main()
{
    constexpr auto N = 999999+1;
    constexpr auto ps = primes<N>{};

    int i;
    while( std::cin >> i ) {
        std::cout << ps.count(i) << std::endl;
    }
}

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

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

int main()
{
    int num,i,count;

    while(scanf("%d",&num)!=EOF){
        count=0;
       for(i=2;i<=num;i++){

        if(isPrime(i))
            count++;
    }
    printf("%d\n",count);
    }
    return 0;
}

C++: //কী পেয়েছো তুমি, কী চেয়েছিলে তুমি.? হিসেবটা তোমার বড়ই গড়মিল...!!//
#include <bits/stdc++.h>
using namespace std;
#define INF 0x3F3F3F3F
typedef long long ll;
vector<ll>v;
ll solve(ll n)
{
    int cnt=0;
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
        if (prime[p])
            cnt++;
   return cnt;
}
int main ()
{
    ll n;
    while((scanf("%lld",&n))!=EOF){
    cout<<solve(n)<<endl;
    }
}
/*
5 6
1 0
0 5
1 2
1 3
2 3
3 4
*/

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

int main(){
	int n;
	int sosu[100000];
	int snum;
	bool judge;

	sosu[0] = 2;

	while(cin >> n){
		snum = 0;
		for(int i = 3; i <= n; i++){
			judge = true;
			for(int j = 0; sosu[j]*sosu[j] <= i; j++){
				if(i%sosu[j] == 0){
					judge = false;
					break;
				}
			}
			if(judge == true){
				snum ++;
				sosu[snum] = i;
			}
		}
		cout << snum + 1 << endl;
	}



	return(0);
}

C++: /*
Volume0-0009
*/
//#include <iostream>
#include <stdio.h>
#include <stdlib.h>

#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE
#define BUFLEN 1024
//using std;

int syserr(char *str)
{
  fputs(str, stderr);
  exit(-1);
}
int main(int argc, char *argv[]){
  int f[N];

  memset(f, TRUE, N);
  f[1]=FALSE;
  for (int i=3; i<N; i++){
    if (f[i] == TRUE ) {
      for (int j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }

  for (int i=3; i<N; i+=2) {
    if (f[i/2-1]) {
      x = x + 1;
    }
    f[i/2-1]=x;
  }
  char buf[BUFLEN];
  while (fgets(buf, BUFLEN, stdin) != NULL){
    int n = atoi(buf);

    int m = 0;
    for (int i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }

    printf("%d\n", m);
 
  exit(0);
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include<fstream>
#include<iostream>
#include<string>
#include<iomanip>
#include<list>
#include<math.h>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<utility>

using namespace std;

bool notprime[1000000];

int main(int argc, char **argv){
	int n;
	int cnt;
	int checkcnt = 0;
	for (int i = 0; i < 1000000; i++) {
		notprime[i] = false;
	}
	while (cin >> n && checkcnt < 30) {
		cnt = 0;
		int i;
		for (i = 2; i < sqrt(n); i++) {
			if (!notprime[i]) {
				cnt++;
				for (int j = 2; j <= n / i; j++) {
					notprime[i * j] = true;
				}
			}
		}
		for (int k = i; k <= n; k++) {
			if (!notprime[k]) {
				cnt++;
			}
		}
		cout << cnt << endl;
		checkcnt++;
	}
	return 0;
}

C++: #include <stdio.h>

#define NUM_MAX (1000000)

int
main(void)
{
	bool a[NUM_MAX];

	for (int i = 0; i < NUM_MAX; i++) {
		a[i] = true;
	}
	for (int i = 2; i*i < NUM_MAX; i++) {
		if (a[i]) {
			for (int j= i*i; j < NUM_MAX; j += i) {
				a[j] = false;
			}
		}
	}
	
	char line[80];
	int n;

	while (fgets(line, sizeof line, stdin)) {
		if (sscanf(line, "%d", &n) == 1) {
			int s = 0;
			for (int i = 2; i <= n; i++) {
				if (a[i]) {
					s ++;
				}
			}

			printf("%d\n", s);
		}
	}

	return 0;
}

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

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

int main(void){
	int n;
	int ans = 0;
	
	cin>>n;
	for(int i=2;i<n;i++){
		if(isPrime(i)) ans++;
	}
	printf("%d\n",ans);

	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data=1,i,j,s[1000000],x;

	while((scanf("%d\n",&data)) != EOF)
	{
		for(i=0;i<=data;i++){
			s[i]=1;}
		x=0;
		if(data<=1){
			printf("%d\n",0);}
		else
		{
			for(i=2;i<=data/2;i++){
			  if(s[i]!=0){
				for(j=i*2;j<data;j+=i)
				    s[j]=0;
			  }
		for(i=0;i<data;i++)
			x+=s[i];
		printf("%d\n",x);
		}
	}
  return 0;
}

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

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

bool IsPrime[1000000];
int PrimeNum[1000000];

int main()
{
    for (int i = 0; i < 1000000; i++)
    {
        IsPrime[i] = true;
    }
    int count = 0;
    PrimeNum[0] = PrimeNum[1] = 0;
    for (int i = 2; i < 1000000; i++) {
        if (IsPrime[i]) {
            count++;
            PrimeNum[i] = count;
            for (int j = 2 * i; j < 1000000; j += i) {
                IsPrime[j] = false;
            }
        }
        else
        {
            PrimeNum[i] = PrimeNum[i - 1];
        }
    }
    int n;
    while (cin >> n)
    {
        cout << PrimeNum[n] << endl;
    }
    return 0;
}