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<stdio.h>
int main(void){
	int i,j,n;
	bool judge[1000000]={0};
	
	for(i=3; i<1000000; i++)if(i % 2 == 0)judge[i] = 1;
	
	for(i=3; i<500000; i+=2){
		if(judge[i]==0){
			for(j=i*2;j<1000000;j+=i){
				if(j % i == 0){
					judge[j]=1;
				}
			}
		}
	}
	
	while(scanf("%d",&n) != EOF){
		int count=0;
		for(i=3;i<=n;i+=2){
			if(judge[i]==0)count++;
		}
		printf("%d\n",count+1);
	}
	return 0;
}

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

const int listmax=1000000;

int main(){
	bool nprime[listmax]={};
	for(int i=2;i<listmax;i++){
		if(nprime[i])continue;
		for(int j=i+i;j<listmax;j+=i){
			nprime[j]=true;
		}
	}
	int n;
	while(cin>>n){
		int sum=0;
		for(int i=2;i<=n;i++){
			if(!nprime[i])sum++;
		}
		cout<<sum<<endl;
	}
	return 0;
}

C++: #include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>
using namespace std;
#include <sstream>
typedef long double ld;
int a;
int isprime(int aa) {
	if (aa == 1)
		return 0;
	for (int i = 2; i * i <= aa; ++i) {
		if (aa % i == 0) {
			return 0;
		}
	}
	return 1;
}

int main() {
	while (cin >> a) {
		int cnt = 0;
		for (int i = 1; i <= a; ++i) {
			if (isprime(i)) {
				cnt++;
			}
		}
		cout << cnt << endl;
	}
}

C++: #include <iostream>
#include <algorithm>
#include<string>
#include<vector>
int main() {
	int n;
	while (std::cin >> n)
	{
		std::vector<bool> v(n + 1 ,false);
		int c = 0;
		v[0] = true, v[1] = true;
		for (int i = 2; i * i <= n ; ++i) {
			if (!v[i]) {
				for (int j = i * i; j <= n; j += i) {
					if (!v[j])c++;
					v[j] = true;
				}
			}
		}

		std::cout << n-c-1 << std::endl;
	}
}

C++: #include<iostream>
#include<cmath>
using namespace std;
bool isPrime(int x)
{
	if (x < 2)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return true;
	for (int i = 3; i <= (int)sqrt(x); i+=2)
		if (x%i == 0)
			return false;
	return true;
}
int main()
{
	int n;
	cin >> n;
	int count = 0;
	for (int i = 1; i <= n; i++)
		if (isPrime(i))
			count++;
	cout << count << endl;
}

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

bool is_sosu(int x){
	int i;
	if(x<2) return false;
	for(i=2;i<=sqrt((double)x);i++){
		if(x%i==0) return false;
	}
	return true;
}

int main()
{
	long int n,x;
	int ans;
	while(cin>>n){
		if(n>=2) ans=1;
		else if(n<2) ans=0;
		
		for(x=3;x<=n;x+=2){
			if(is_sosu(x)==true) ans++;
		}
		cout<<ans<<endl;
	}
}

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

int main(void) {

  int x;
  while(cin >> x){


    bool array[max_n];

    for(int i = 0; i < max_n; i++) {
      array[i] = true;
    }

    array[0] = false;
    array[1] = false;
    for(int i = 2; i < max_n; i++) {
      for(int j = 2; j < max_n; j++) {
        if(i * j > max_n) break;
        array[i * j] = false;
      }
    }

    int count_sosu = 0;

    for(int i = 0; i <= x; i++) {
      if(array[i] == true) count_sosu++;
    }

    cout << count_sosu << endl;
  }
  return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data=0,i=0,j=2,k=0,l=0,kai[100]={0},s[10000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		{
			kai[k]=0;
		}
		else
		{
			for(i=2;i<data;i++)
				s[i]=i;
		
			for(i=2;i*2<data;i++)		
			{
				for(j=2;j*i<data;j++)				
					s[j*i]=0;
			}
			for(i=2;i<data;i++)
			{	
				if(s[i]!=0)
				{
					l+=1;
				}
			}
		}
		kai[k]=l;
		k+=1;
	}

  for(j=0;j<k;j++)
    printf("%d\n",kai[j]);
  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;
		data[0] = data[1] = false;
		for (int i = 2;i <= n;i++) {
			if (data[i]) {
				count++;
				for (int j = i + i;j <= n;j += j) {
					data[j] = false;
				}
			}
		}
		cout << count << endl;
		delete[] data;
	}
	return 0;
}

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

C++: #include <stdio.h>

long MAX=999999;

int main(void){
    long int s[1000000]={0},k=0,i,j,n;
    
    s[0]=s[1]=1;
    
    for(i=2;i<=MAX;i++){
        if( !s[i] ){
            k++;
            for(j=2;j*i<=MAX;j++){
                s[j*i]=-1;
            }
        }
        s[i]=k;
    }
    
    
    while(EOF != scanf("%ld",&n)){
        printf("%ld\n",s[n]);
    }
    
    
    return 0;
}

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

int main(void) {
    int N=999999;
    int p[N];
    p[0]=0;
    for (int i=1; i<N; i++){
        p[i] = 1;
    }
    for (int i=1; i<N; i++){
        if (p[i]==1){
            int n=i+1 , m=2*n;
            while (m<=N){
                p[m-1] = 0;
                m += n;
            }
        }
    }
    int n , s;
    while (1){
        cin >> n;
        s=0;
        if (cin.eof()){
            for (int i=0; i<n; n++){
                if (p[i]==1)
                    s+=1;
            }
            cout << s << endl;
        }
    }
    return 0;
}

C++: ///bismillah_hir_rahmanir_rahim

#include<bits/stdc++.h>
using namespace std;
#define n 999999


int i,j,p,f;

int arr [n];

void seive ()
{

    //arr[0]=arr[1]=1;
    arr[2]=0;

    for (i=4; i<=n; i=i+2)
    {
        arr[i]=1;
    }

    for(i=3; i<=sqrt(n); i=i+2)
    {
        if(arr[i]==0)
        {
            for( j=i*i; j<=n; j=j+(2*i) )
            {
                arr[j]=1;

            }
        }
    }

//printf("%d\n",arr[5]);

//    for( p=2; p<=100; p++)
//    {
//        if(arr[p]==0)
//        {
//            printf("%d ",p);
//        }
//    }


}

int main()
{

    seive();

    int num,count,p;

    while ( scanf("%d",&num)==1)
    {
        count = 0;

        for( p=2; p<=num; p++)
        {
            if(arr[p]==0)
            {
                count++;
            }
        }
        printf("%d\n",count);
    }
    return 0;
}

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

typedef unsigned long long ull;

ull qtde[1000000] = { 0, 0, 1, 2 };

bool isPrime(ull x) {
  ull i = 6;
  ull root = (ull)sqrt(x) + 2;
	if (x <= 1)
		return false;
  if (x == 2 || x == 3)
    return true;
  if (x % 2 == 0 || x % 3 == 0)
    return false;

  while (i <= root) {
    if (x % (i - 1) == 0)
      return false;
    if (x % (i + 1) == 0)
      return false;
    i += 6;
  }

  return true;
}

int main(int argc, char const *argv[]) {
    ull n;
    ull i;
    
    for (int i = 3; i < 1000000; i++)
      qtde[i] = qtde[i-1] + isPrime(i);

    while (cin >> n)
      cout << qtde[n] << endl;

    return 0;
}