Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 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);
}

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