Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	num := make([]bool, 1000000)

	for sc.Scan() {
		var nmpr int

		n, _ := strconv.Atoi(sc.Text())

		lmt := int(math.Sqrt(float64(n)))

		for i := 2; i <= lmt; i++ {
			for j := 2; i*j <= n; j++ {
				if !num[i*j] {
					num[i*j] = true
				}
			}
		}

		for t := 2; t <= n; t++ {
			if !num[t] {
				nmpr++
			}
		}

		fmt.Println(nmpr)
	}

}

C++: #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#define N 999999
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = (int) sqrt(N);
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(){
  int c, i, j;
  long int k;
  char buf[7];
  long int n;
  long int count;

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    printf("%ld\n", count);
    if(c == EOF) break;
  }
  return 0;
}

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

using namespace std;

int main()
{
	unsigned int  n;
	cin >> n;
	unsigned int num, count = 0;
	for(int i = 0; i < n; i++)
	{
		cin >> num;
		for(int j = 2; j <=num; j++)
		{
			if(num == j)count++;
			if(num % j == 0)
			{
				break;
			}
		}
	}
	cout << count << endl;
	return 0;
}

C++: #include <stdio.h>

int main(){
	int sosuu[] = { 2, 3, 5 }, i, x, y = 3,n=0,z;
	
	while (scanf("%d", &n)!=EOF){
		z = 0; 
		for (i = 3; i < n + 1; i += 2){
			for (x = 0; x < y; x++){
				if (i % sosuu[x] == 0){ break; }
				if (x + 1 == y){ sosuu[y] = i, y++;}
			}
		}
		for (i = 0; i < y; i++){ if (sosuu[i] > n)break; z++; }
		printf("%d\n", z);
	}
	return 0;
}

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

int prime(int a){

int i,p;

	
	if(a == 2) return 1;
	if(a % 2 == 0) return 0;
		p = sqrt(a);
	for(i=3;i<=p;i+=2){
		if(a%i == 0) return 0;
	}
return 1;
}

int main(void){
	
	int a,i,count=0;
	
	while(scanf("%d",&a) != EOF){;
	
	for(i=2;i<=a;i++){
		
		count += prime(i);
	}
	
	printf("%d\n",count);
}

return 0;
}

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

using namespace std;

int isprime(int x){
	int i;
	for(i = 3; i <= sqrt(x); i += 2){
		if(x % i == 0) return 0;
	}
	return 1;
}

int main(){
	int n, i, count;
	while(cin >> n){
		count = 0;
		for(i = 2; i <= n; i++){
			if(i == 2 || i == 3) count++;
			else if(isprime(i) == 1 && i % 2 != 0) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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

int sosu(int num){
	int i,j;
	int flag=0;
	int ans=1;
	
	for(i=3;i<=num;i+=2){
		for(j=3;j<=sqrt(num);j+=2){
			if(i==j)j++;
			if(i%j==0){
				flag=1;
				break;
			}
		}
	if(flag==0)ans++;
	flag=0;
	}
	return ans;
}

int main(){
	int num;
	int ans=0;
	int i,j,k;
	int box[1000000];
		
	while(scanf("%d",&num)!=EOF){
		
		for(i=2;i<=num;i++)box[i]=1;
		
		for(i=2;i<=sqrt(num);i++){
			if(box[i]==1){
				for(j=2;i*j<=num;j++){
					box[i*j]=0;
				}
			}
		}
		for(i=0;i<=num;i++)if(box[i]==1)ans++;
		printf("%d\n",ans);
		ans=0;
	}
	return 0;
}

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);
}