Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 3; i <= num; i += 2 { //1を除く入力値以下の数字
			for j := 3; j < i; j += 2 {
				if i%j == 0 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count + 1)
	}
}

C++: #include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <vector>

std::vector<std::size_t> prime_table = {2};

void make_prime_table(const std::size_t n)
{
    const std::size_t found_last_prime = prime_table.back();
    if(found_last_prime < n)
    {
        std::list<std::size_t> undefined_table;

        for(std::size_t i = found_last_prime + 1; i <= n; ++i)
        {
            undefined_table.push_back(i);
        }

        const std::size_t sn = std::sqrt(n);
        for(std::size_t p = 0; prime_table.back() <= sn; ++p)
        {
            for(auto u = undefined_table.begin(); u != undefined_table.end();)
            {
                if(0 == *u % prime_table[p])
                {
                    u = undefined_table.erase(u);
                }
                else
                {
                    ++u;
                }
            }
            if(undefined_table.empty())
            {
                break;
            }
            if(found_last_prime <= prime_table[p])
            {
                prime_table.push_back(undefined_table.front());
                undefined_table.pop_front();
            }
        }
        prime_table.insert(prime_table.end(), undefined_table.begin(), undefined_table.end());
    }
}

std::vector<size_t> prime_acc = {0};

std::size_t prime_size(const std::size_t limit)
{
    if(prime_acc.size() <= limit)
    {
        make_prime_table(limit);
        auto it = prime_table.begin();
        while(prime_acc.size() <= limit)
        {
            it = std::lower_bound(it, prime_table.end(), prime_acc.size());
            if(it != prime_table.end())
            {
                prime_acc.insert(prime_acc.end(), *it - prime_acc.size(), prime_acc.back());
                prime_acc.push_back(prime_acc.back() + 1);
            }
            else
            {
                prime_acc.insert(prime_acc.end(), limit - prime_acc.size() + 1, prime_acc.back());
            }
        }
    }
    return prime_acc[limit];
}

int main()
{
    std::size_t n;

    while(std::cin >> n, !std::cin.eof())
    {
        std::cout << prime_size(n) << std::endl;
    }
}

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

int main(void){
int unti[100002] = {0};
fill(unti,unti + 100002,0);
for(int n = 2;n < 100002;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100002;a++)
{
	unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
}
return 0;
}

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

using namespace std;

#define N 100000

int main(){

    bool primes[N];
    int  n; 

    fill(primes, primes + N, true);
    primes[0] = false;
    primes[1] = false;
    
    for(int i = 2; i < N; ++i){
        if(primes[i]){
            for(int j = i + i; j < N; j += i)primes[j] = false;
        }
    }

    while(cin >> n){
        int  count = 0;
        for(int i = 2; i <= n; ++i){
            if(primes[i])count++;
        }
        cout << count << endl;
    }
    
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int N,count=0;
	cin >> N
	for(int x=2;x<=N;x++){
		int flag = 0;
		for(int y=2;y<x;y++){
			if((x%y)==0)	flag = 1;
		}
		if(flag == 0)	count++;
	}
	cout << count << endl;
	return 0;
}

C++: #include<bits/stdc++.h>
# define max 1000000
int a[max];
int a1[max];
int main()
{
    long m,n,i,j,k,l,c;
    for(i=2; i<max; i++) a[i]=1;
    k=2;
    for(i=2; i*i<=max; i++)
    {
        for(j=k+k; j<max; j=j+k) a[j]=0;
        k++;
        for(; !a[k]; k++);
    }
    a1[1]=0;
    c=1;
    for(i=2; i<max; i++)
    {
        if(a[i])
        {
            a1[i]=c;
            c++;
        }
        else a1[i]=c;
    }
    while(scanf("%ld",&n)==1)
    {
        if(n==1)
        {
            printf("0\n");
            continue;
        }
        if(a[n]) printf("%d\n",a1[n]);
        else printf("%d\n",a1[n]-1);
    }
    return 0;
}

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

int main()
{

	int n,k,p[100000];
	p[0]=2;
	while(cin>>n){
	k=0;
	for(int i=3;i<=n;i++){
		for(int j=0;j<=k;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				p[k]=i;
			}
		}
	}

	cout<<k+1<<endl;
	}
}

C++: //Prime Number

#include<cstdio>
using namespace std;

int Isprime[1000000];
int prime[1000000];      //?´???°?????????????????????

//??¨??????????????????????????????????´???°?????????
void a_prime(){
    int n = 1000000;
    int p = 0;
    //??????????????§???????????????
    for(int i = 0; i < n; i++) Isprime[i] = 1;
    //0??¨1????´???°??§??????
    Isprime[0] = Isprime[1] = 0;
    for(int i = 2; i < n; i++){
        if(Isprime[i]) prime[p++] = i;
        for(int j = 2*i; j < n; j += i){
            Isprime[j] = 0;
        }
    }
    
    //?´???????????????£?????????
    for(int i = 1; i < n; i++) Isprime[i] += Isprime[i-1]; 
    
}


int main(void){
    int no;
    a_prime();
    while(scanf("%d", &no) != EOF){
        printf("%d\n", Isprime[no]);
    }
    
    return 0;
}

C++: #include<iostream>
#include<math.h>
#define MAX 100000
using namespace std;
int main(){
	bool p[MAX+1];
	int n,count;
	for(int i=2; i<=MAX; i++)
		p[i] = true;
	for(int i=2; i<=sqrt(MAX); i++){
		if(p[i] == true){
			for(int j=2*i; j<=MAX; j++){
				if(j%i == 0)
					p[j] = false;
			}
		}
	}
	while(cin >> n){
		count = 0;
		for(int i=0; i<=n; i++){
			if(p[i] == true)
				count++;
		}
		cout << count << endl;
	}
}

C++: #include <stdio.h>
const int MAX_V = 1000000;
int prime[MAX_V + 1];
int sum[MAX_V + 1];
int main() {
  int i, k, v, n, max = 0;
  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", &n) != EOF){
    for(i = 2;i <= n;i++){
      sum[n] += prime[i];
    }
  printf("%d\n", sum[n]);
  }
  return 0;
}

C++: #include<iostream>

using namespace std;

int main() {
    int n = 999999;
    char* p;
    int t = 2;

   

    p = new char[n];
    for(int i = 0; i < n; i++) {
        p[i] = 1;
    }
    p[0] = p[1] = 0;
    
    for(int i = 3; i < n; i++) {
        if(p[i] == 0)
            continue;
        for(int point = 2; point < n; point += i) {
            p[point] = 0;        
        }
    }
    
    while(cin >> n) {
        int c = 0;
        for(int i = 1; i <= n; i++) {
            if(p[i]) {
                c++;
            }
        }
        cout  << c << endl;
    }



    return 0;
}

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

int main()
{
	long int n,m;
	while(cin>>n){
		long int i;
		int number[100000]={0};
		int ans=0;

		for(i=0;i<n;i++){
			if(number[i]==0){
				ans++;
				for(m=i;m<n;m+=i){
					number[m]=1;
				}
			}
		}
		cout<<ans<<endl;
	}
}

C++: /*
Volume0-0009
*/
#include <iostream>
#include <stdlib.h>
#include <string.h>

#define N 1000000
#define TRUE (int)(0==0)
#define FALSE !TRUE
#define BUFLEN 1024

using namespace std;

int main(int argc, char *argv[]){
  int f[N];

  //  memset(f, TRUE, N);
  f[0]=FALSE;
  f[1]=FALSE;
  for (int i=2; i<N; i++)
    f[i] = TRUE;

  for (int i=2; i<N; i++){
    if (f[i] == TRUE ) {
      for (int j=i+i; j<N; j+=i){
	f[j] = FALSE;
      }
    }
  }

  while (cin >> int n) != NULL){
    int m = 0;
    for (i=1; i<=n; i++){
      if (f[i]){
	m++;
      }
    }
    cout << m;
  }
 
  exit(0);
}