Go: package main

// https://ja.wikipedia.org/wiki/%E3%82%A8%E3%83%A9%E3%83%88%E3%82%B9%E3%83%86%E3%83%8D%E3%82%B9%E3%81%AE%E7%AF%A9

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

var scanner = bufio.NewScanner(os.Stdin)

func nextString() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() (int, error) {
	return strconv.Atoi(nextString())
}

func main() {
	scanner.Split(bufio.ScanWords)

	for {
		n, err := nextInt()
		if err != nil {
			break
		}
		maybePrime := make([]bool, n+1)
		for i := 0; i <= n; i++ {
			maybePrime[i] = true
		}

		maybePrime[0] = false
		maybePrime[1] = false
		for i := 2; i <= int(math.Sqrt(float64(n)))+1; i++ {
			j := i * 2
			for j <= n {
				maybePrime[j] = false
				j += i
			}
		}

		nPrimes := 0
		for _, p := range maybePrime {
			if p {
				nPrimes++
			}
		}
		// fmt.Println(maybePrime)
		fmt.Println(nPrimes)
	}
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in, int start){
	int count = 0;
	if (in > 2)	count++;
	for (int i = start; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in, count500000 = PrimeNumber(500000, 3);

	while (cin >> in, !cin.eof()){
		if (in <= 500000)
			cout << PrimeNumber(in, 3) << endl;
		else
			cout << count500000 + PrimeNumber(in, 500001) << endl;
	}
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
int max=1;
while(cin>>n){
for(int i=3;i<=n;i+=2){
for(int j=2;j<=i/2+1;j++){
if(i%j==0){max++;goto A;}
}
A:
;
cout<<max<<endl;
max=1;
}
}
}

C++: #include <iostream>
#include <vector>
#include <queue>
#include <string>
#include <cstdio>
#include <cmath>
#include <sstream>
#include <algorithm>

using namespace std;

bool isPrime(int n) {
	if (n == 2)return true;
	if (n < 2 || n % 2 == 0) return false;
	int i = 3;
	while (i <= sqrt(n)) {
		if (n%i == 0) return false;
		i = i + 2;
	}
	return true;
}

int main() {
	int a, count;
	vector<int> v;
	for (int i = 0; i <= 999999;i++) {
		if (isPrime(i)) v.push_back(i);
	}

	while (cin >> a) {
		count = 0;
		for (int i = 0; i <v.size()+1; i++) {
			if (v.size() + 1 == i) {
				count = i;
				break;
			}
			if (v[i] > a) {
				count = i;
				break;
			}
		}
		cout << count << endl;
	}
}

C++: //
#include <iostream>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>

using namespace std;

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

int num_prime(int n){
	int counter = 0;
	for(int i=2; i<=n; i++){
		if(isPrime(i)) counter++;
	}
	return counter;
}


int main(){
	int n;
	while(cin >> n){
		cout << num_prime(n) << endl;
	}

	return 0;
}

C++: #include<stdio.h>

int main(){
  const int MAX_V = 1000000;
  int prime[MAX_V+1];
  int i, k, v;
  int ans;
  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;
      }
    }
  }
  while(scanf("%d", &v) != EOF){
    int count = 0;
    for(k = 2; k <= v; k++){
      ans = prime[k];
      if(ans == 1){
        count++;
      }
    }
    printf("%d\n", count);
  }
  return 0;
}

C++: #include<stdio.h>

int main(void){
	const int MAX_V = 1000000;
	int prime[MAX_V+1],sum[MAX_V];
	int i,k,n,ans;
	for(i=2;i<=MAX_V;i++){
		prime[i] = 1;
		sum[i] = 0;
	}
	for(i=2;i*i<=MAX_V;i++){
		if(prime[i]==1){
    	for(k=2*i;k<=MAX_V;k+=i){
				prime[k] = 0;
			}
		}
	}
  for(i=2;i<=MAX_V;i++){
		sum[i+1]=sum[i]+prime[i];
  }
  while(scanf("%d",&n) != EOF){
    ans = sum[n+1];
    printf("%d\n",ans);
  }
  return 0;
}

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

bool IsPrime(int n){

    if(n % 2 == 0)
        return false;
 
    for(int i = 3; i * i <= n; i += 2)
         if(n % i == 0)
            return false;
    return true;
}
int CheckNum(int input){
	int count = 1;

	for(int i = 2; i < input; ++i){

		if(IsPrime(i)) ++count;
	}
	return count;
}
int main() {
	int input;

	while(cin >> input)
	cout << CheckNum(input) << endl;
}

C++: #include <iostream>
#include <vector>
#include <numeric>
using namespace std;
int main() {
  int n;
  while (cin >> n) {
    vector<int> v;
    v.resize(n + 1);
    fill(v.begin(), v.end(), 1);
    v[0] = 0;
    v[1] = 0;
    for (int i = 0; i * i < v.size(); ++i) {
      while (v[i] == 0) ++i;
      for (int m = i + 1; m * m < v.size(); ++m) {
        if (m % i == 0) {
          v[m] = 0;
        }
      }
    }
    cout << accumulate(v.begin(), v.end(), 0) << endl;
  }
  return 0;
}

C++: #include<stdio.h>
#include<vector>
using namespace std;
int s[1000000];
int main()
{
	int   i,j,k,n,u;
	s[0]=2;k=1;
	for(i=3;i<100000;i++)
	{for(j=0;j<k;j++)
	if(i%s[j]==0)break;
	if(j==k)s[k++]=i;}
	while(~scanf("%d",&u))
	{for(j=0;j<k;j++)
	if(u<s[j])break;
	printf("%d\n",j);}
	return 0;
}

C++: #include<stdio.h>

int main(){
    int i,j,k,n,f;
    int stack[30],sp=0;
    while(scanf("%d",&stack[sp++])!=EOF);
    for(i=0;i<sp-1;i++){
        n=0;
        for(j=2;j<=stack[i];j++){
            f=0;
            for(k=2;k<j;k++)
                if(j%k==0)f=1;
            if(f==0)n++;
        }
        printf("%d\n",n);
    }
    return 0;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[100005];


int main()
{
	int n;
	while (cin >> n)
	{

		int ans = 0;

		REP(i, 100005)prime[i] = true;
		prime[0] = prime[1] = false;
		FOR(i, 2, (int)sqrt(100005))
		{
			if (prime[i] == true)
			{
				FOR(j, 2, (int)sqrt(100005)){
					if (prime[i*j] == true)prime[i*j] = false;
				}
			}
		}
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
typedef long long ll;
ll prime[1000001];
ll length = 0;
void insert(ll p) { prime[length] = p; length++; return; }
int main(){
	insert(2);
	for (ll i = 3; i < 1000000; i += 2) {
		for (ll j = 0; j < length; j++)
			if (i%prime[j] == 0)goto cont;
			else if (prime[j] > sqrt(i))break;
		insert(i);
	cont:;
	}
	ll n; while (cin >> n) {
		ll ans = 0;
		while (prime[ans] <= n){
			ans++;
		}
		cout << ans << 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]=v[1]=false;
    for(int i = 2;i<1000;i++){
      if(v[i]){
        for(int j=i*i;j<MAX;j+=i){
         v[j]=false;
       }
      }
    }
    for(int i = 2;i<MAX;i++)v[i]+=v[i-1];
    while(true){
      int a;
      cin >> a;
      if(cin.eof())break;;
      cout << v[a] << endl;
    }
    return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;
int prime[MAX_V+1];
int a[MAX_V] = {'0'};
int sum[MAX_V+1];
int main() {
  int i, k, v, j, m, n;
  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;
      }
    }
  }
  sum[0] = 0;
  for(m = 0; m < MAX_V; m++) {
    sum[m+1] = sum[m] + prime[m];
  }
  while( scanf( "%d", &n ) != EOF ) {
    for( j = 2; j <= n; j++ ) {
      int isprime = prime[j];
      int isprimee = prime[j-2];
    }
    printf( "%d", sum[n+1] );
  }
  return 0;
}