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 <cstdio>
#include <vector>
using namespace std;
const int MAX_N = int(1e6);

int main(){

    int n, i, j, maxin = 2;
    bool jud;
    vector <int> vec;
    for (i = 2; i <= MAX_N; i++){
        jud = 0;
        for (j = 0; j < vec.size(); j++){
            if (vec[j] * vec[j] > i) break;
            if (!(i % vec[j])){
                jud = 1;
                break;
            }
        }
        if (!jud)
            vec.push_back(i);
    }
    while (cin >> n){
        cout << upper_bound(vec.begin(), vec.end(), n) - vec.begin() << endl;
    }
}

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

#define N 1000000

using namespace std;

int main(){

  int n, root;
  int p[N][2] = {0};

  for(int i=2; i<N; i++){
    p[i][0] = 1;
  }

  for(int i=2; i<N; i++){
    root = (int)sqrt(i) + 1;
    for(int j=2; j<root; j++){
      if(p[j][0] == 1){
        if(i % j == 0){
          p[i][0] = 0;
          break;
        }
      }
    }
  }

  for(int i=2; i<N; i++){
    p[i][1] = p[i-1][1] + p[i][0];
  }

//  for(int i=0; i<30; i++){
//    cout << i << " " << p[i][0] << endl;
//  }

  while(cin >> n){
    cout << p[n][1] << endl;
  }

  return 0;
}

C++: #include <stdio.h>

int isPrime(int n);

int main(void){
    int n;
    int cnt;

    while (scanf("%d", &n)!= EOF){
        cnt = 0;
        for(int i=2; i<=n; i++){
            if (isPrime(i)) cnt++;
        }
        printf("%d\n", cnt);
    }

    return 0;
}


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

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

const int NUM = 1000000;

int main() {
  int n;
  bool isPrime[NUM];
  int dp[NUM];
  for (int i=0;i<NUM;i++) {
    isPrime[i] = 1;
    dp[i] = 0;
  }
  isPrime[0] = isPrime[1] = 0;
  for (int i=2;i<NUM;i++) {
    if (isPrime[i]) {
      dp[i] = 1;
      for (int j=i*2;j<NUM;j+=i) {
        isPrime[j] = 0;
      }
    }
  }
  for (int i=1;i<NUM;i++) {
    dp[i] += dp[i-1];
  }

  while (cin >> n) {
    cout << dp[n] << endl;
  }
  return 0;
}

C++: 
#include<iostream>
using namespace std;
int sushu[1000010];
int n;
bool isPrime(int a){
	if (sushu[a] != -1){
		return sushu[a] == 0 ? false : true;
	}
	int i;
	for (i = 2; i < a; ++i){
		if (a%i == 0){
			sushu[a] = 0;
			return false;
		}
	}
	sushu[a] = 1;
	return true;
}
int main()
{
	memset(sushu, -1, sizeof(sushu));
	while (cin >> n){
		for (int i = 2; i <= n; ++i){
			if (isPrime(i))
				cout << i << endl;
		}
	}
	return 0;
}

C++: #include <bits/stdc++.h>
using namespace std;

int main(){
	int n;
	while(cin>>n){
		int cnt=0;
		vector<bool> v(n+1,true);
		for(int i=2; i<=sqrt(n); i++){
			if(v[i]){
				for(int j=2; i*j<=n;j++){
						v[i*j]=false;
				}
			}
		}
		for(int i=2;i<=n;i++){
			if(v[i])
				cnt++;
		}
		cout << cnt << endl;
	}
}

C++: #include <cstdio>

int main(void) {
	int n, ans = 0;
	scanf("%d", &n);
	for(int i = 2; i < n; i++) {
		bool flag = false;
		for(int j = 2; j < i; j++) {
			if(i % j == 0)
				flag = true;
		}
		if(flag)
			ans++;
	}
	printf("%d\n", ans);
	return 0;
}

C++: #include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
 
vector<bool> GetPrimeTable(int n)
{
	vector<bool> IsPrimeNumber(n+1, true);
	for(int i = 2; i <= n; i++){
		while(IsPrimeNumber[i] == false){
			i++;
		}
		for(int j = 2; i*j <= n; j++){
			IsPrimeNumber[i*j] = false;
		}
	}
	return IsPrimeNumber;
}

int GetPrimeCount(vector<bool>& PrimeTable, int n)
{
	int Count = 0;
	for(int i = 2; i <= n; i++){
		if(PrimeTable[i] == true){
			Count++;
		}
	}
	return Count;
}

int main()
{
	vector<bool> PrimeTable = GetPrimeTable(999999);
	while(true){
		int Nubmer;
		cin >> Nubmer;
		if(cin.eof() == true) break;
		cout << GetPrimeCount(PrimeTable, Nubmer) << endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
	int n;
	int count;
	while (1)
	{
		cin >> n;
		if (cin.fail()) break;

		bool *isPrime;
		isPrime = new bool[n + 1];
		memset(isPrime, true, sizeof(bool) * (n + 1));
		isPrime[0] = isPrime[1] = false;
		
		count = 0;
		for (int i = 2; i <= n; ++i)
		{
			for (int j = i + i; j <= n; j += i)
			{
				isPrime[j] = false;
			}
		}
		for (int i = 0; i <= n; ++i)
		{
			if (isPrime[i] == true)
				++count;
		}
		cout << count << endl;
		delete[] isPrime;
	}
	return 0;
}

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

int main() {
	const int MAX_V = 1000000;
	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);
	int count = 0;
	for(i=0;i<=v;i++){
		int isprime = prime[i];
		if(isprime) count ++;
	}
	printf("%d",count);
	return 0;
}

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

const int size = 1000000;
int n[size];

int main() {
    for(int i = 0 ; i < size ; ++i) {
		n[i] = (i < 2) ? false : true;
	}
    for (int i = 0; i < std::sqrt(size); ++i) {
        if (n[i]) {
            for (int j = 2; i * j < size; ++j) {
                n[i * j] = false;
            }
        }
    }
    
    int m;
    while (~scanf("%d\n", &m)) {
        int ans = 0;
        for (int i = 0; i <= m; ++i) {
            if (n[i]) {
                ++ans;
            }
        }
        printf("%d\n", ans);
    }
}

C++: #include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

// Eratosthenesの篩
vector<bool> primeno(1000010, true);
void Eratosthenes(int n) {
    primeno.at(0) = primeno.at(1) = false;
    int limit = sqrt(n);
    for(int i = 2; i < limit; ++i) {
        if(primeno.at(i)) {
            for(int j = 0; i*(j+2) < n; ++j) {
                primeno.at(i*(j+2)) = false;
            }
        }
    }
}

vector<int> primecnt(1000010, 0);

int main() {
    Eratosthenes(1000000);
    ll n;
    for(int i = 0; i < 1000000; ++i) {
        if(primeno.at(i)) primecnt.at(i)++;
        primecnt.at(i+1) += primecnt.at(i);
    }
    while(cin >> n) {
        cout << primecnt.at(n) << endl;
    }
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main(){
int n;
while(cin >> n,!cin.eof()){
vector<int> prime;
prime.push_back(2);//ôðÈ­½ß2ÍÅÉüêÄ¨­
bool flag;
for(int x=3;x<=n;x+=2){
flag=true;
for(int y=0;prime[y]*prime[y]<=x;y++){
if(!(x%prime[y])){
flag=!flag;
break;
}
}
if(flag)prime.push_back(x);
}
cout << prime.size() << endl;
}
return 0;
}