Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FIR first
#define SEC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

bool Is_Prime(int n){
  if(n==1) return false;
  for(int i=2;i*i<=n;i++){
    if(n%i==0){
      return false;
    }
  }
  return true;
}
vector<int> prime;

signed main(){
  LOOP(i,1,1000000){
    if(Is_Prime(i))prime.PB(i);
  }
  int n;
  while(cin>>n){
    int ans=0;
    REP(i,prime.size()){
      if(prime[i]<=n)ans++;
      else break;
    }
    cout<<ans<<endl;
  }
  return 0;
}

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

int main(int argc, char *argv[]) {
	using namespace std;
	
	int line;
	while (EOF != fscanf(stdin, "%d", &line)) {
		vector<bool> sieve(line, true);
		int prmCount = 0;

		for (int i = 2; i <= line; i++) {
			if (sieve[i]) {
				prmCount++;
				for (int j = i+i; j <= line; j+=i) {
					sieve[j] = false;
				}
			}
		}
		printf("%d\n", prmCount);
	}
	

	return 0;
}

C++: #include <iostream>

using namespace std;

#define M 10000000
bool prime[M];
int main()
{
	
	int ans, n;

	for (int i = 2; i * i < M; i++){
		if (prime[i] == false){
			for (int j = i; j < M; j += i){
				if (!(i == j)) {
					prime[j] = true;
				}
			}
		}
	}
	while (cin >> n){
	  ans = 0;
		for (int i = 2; i <= n; i++){
			if (prime[i] == false) ans++;
	  }
		cout << ans << endl;
	}
	return (0);
}

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

int main() {
	int n, count;
	bool *data;

	while (cin >> n) {
		data = new bool[n + 1];
		count = 0;
		for (int i = 0;i <= n;i++) data[i] = true;
		for (int i = 2;i <= n;i++) {
			if (data[i]) {
				count++;
				for (int j = i + i;j <= n;j += i) {
					data[j] = false;
				}
			}
		}
		cout << count << endl;
		delete[] data;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
#define MAX_N 999999 + 16
 
int  prime[MAX_N];          
bool is_prime[MAX_N + 1];   
int sieve(const int& n)
{
    int p = 0;
    fill(is_prime, is_prime + n + 1, true);
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= n; ++i)
    {
        if (is_prime[i])
        {
            prime[p++] = i;
            for (int j = 2 * i; j <= n; j += i)
            {
                is_prime[j] = false;
            }
        }
    }
    return p;
}
 

int main()
{
    int n;
    while (cin >> n)
    {
        cout << sieve(n) << endl;
    }
    return 0;
}

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

int main() {
	static bool cmp[1000000] = { true };
	static int npr[1000000];
	for (int i = 2; i<1000000; i++) {
		if (!cmp[i]) {
			for (int j = 2; j*i<1000000; j++) {
				cmp[i*j] = true;
			}
		}
		npr[i] = npr[i - 1] + !cmp[i];
	}
	int n;
	while (cin >> n) {
		cout << npr[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<vector>
#define MAX 1000000
using namespace std;
int main(){
    vector<int> v(MAX);
    for(int i = 0;i<MAX;i++)
      v[i]=true;

      v[0]=false;
      v[1]=false;
    for(int i = 2;i<MAX;i++){
      if(v[i]==true){
        for(int j = i;j<MAX;j=j*j){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())return 0;
      cout << v[a]<<endl;
    }
}

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i;
	if(x == 2){
 		return 1;
	}
  	if(x<2||x%2==0){
		return 0;
	}
	i = 3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main(){
	int l[999999]={0};
	int r=0,n;
	for(int i=0;i<999999;i++){
		if(isprime(i+1)){
			r++;
			l[i]=r;
		}
	}
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",l[n-1]);
	}
	return 0;
}

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

int main(){
  int n,prime[1000001],key,lf=0;
  prime[0]=2;
  key=1;
  for(int i=3;i<=3000000;i+=2)
    {
      for(int j=2;j<=sqrt(i);j++)
	{
	  if(i%j == 0)
	    {
	      lf=1;
	      break;
	    }
	}
      if(lf == 1)
	{
	  lf=0;
	}
      else 
	{
	  prime[key]=i;
	  key++;
	}
    }

  while(cin >> n)
{
  int cou=0;
  for(int i=0;;i++)
    {
      if(prime[i] <= n)
	{
	  cou++;
	}
      else break;
    }

  cout << cou << endl;
 }
}

C++: #include<iostream>
using namespace std;
int main(){
	int n,i,j,c=0;
	while(cin>>n){
		for(i=2;i<n;i++){
			for(j=2;j<i;j++){
				if(i%j==0){break;}
			}
			if(i==j){c++;}
		}
		cout<<c<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

C++: #include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
#define Max 1000000
bool vis[Max];
int prime[Max],cnt;
void print_prime()
{
    memset (vis,false,sizeof (vis));
    for (int i=2;i<=sqrt(Max);i++)
        if (!vis[i])
        for (int j=i*i;j<=Max;j+=i)
        vis[j]=true;
    for (int i=2;i<=Max;i++)
        if (!vis[i])
        prime[cnt++]=i;
}
int main()
{
    print_prime();
    int n;
    while (scanf("%d",&n)!=EOF) {
        int i=0;
        while (prime[i]<=n) {
            i++;
        }
        printf("%d\n",i);
    }
    return 0;
}

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

int main() {
    const int MAX = 1000000;
    bool isPrime[MAX];
    fill_n(isPrime, MAX, true);
    for (int i = 4; i < MAX; i += 2) {
        isPrime[i] = false;
    }
    for (int i = 3; i * i <= MAX; i += 2) {
        if (isPrime[i]) {
            for (int j = 2 * i; j < MAX; j += i) {
                isPrime[j] = false;
            }
        }
    }
    int n;
    while (cin >> n) {
        int count = 0;
        for (int i = 2; i <= n; i++) {
            count += isPrime[i];
        }
        cout << count << endl;
    }
}

C++: #include <stdio.h>
#include <string>
#include <iostream>

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    int temp = 0;
    while(scanf("%d",&n)!=EOF){
        if(n==1){
            printf("%d",0);
        }else{
            for(int i=2; i<=n; i++ ){
                temp+=sosuu(i);
            }
            printf("%d",temp);
        }
    }
    
    
}

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