Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

C++: #include<iostream>
using namespace std;
int main(){
	int n=0,K=0;
	while(cin>>n){
		for(int i=2;i<=n;i++){
			int c=0;
			for(int x=2;x<i;x++){
				if(i%x==0){
					c=c;
				}
				else{
					c++;
				}
			}
			if(c==i-2){
				K++;
			}
		}
		cout<<K;
		K=0;
	}
}

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

using namespace std;

#define N 1000000

int main(){

    bool primes[N];
    int  n; 

    fill(primes, primes + (sizeof primes / sizeof *primes), true);
   
    primes[0] = false;
    primes[1] = false;
    
    for(int i = 2; i + 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>
#include<string>
using namespace std;

int main(){
	int num;
	int count = 0;
	int i,j;

	//cout << "数字を入力してください" << endl << "number :";
	cin >> num;

	for(i=2; i<num; i++){
		for(j=2; j<i; j++){
			if(i%j ==0){
				break;
			}
		}
		if(j == i){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

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

static const long MAX = 1000000L;
 
int main() {
    vector<long> prime;
    bool isPrime;
    long n;
 
    long i, len = sqrt(MAX) + 1;
    long j, lenJ;
    long k;
     
    prime.push_back(2);

    for (i = 3; i <= len; i += 2) {
        isPrime = true;
        lenJ = prime.size();
        k = sqrt(i) + 1;
        for (j = 0; j < lenJ; j++) {
            if (k <= prime[j]) break;

            if (i % prime[j] == 0) {
                isPrime = false;

                break;
            }

        if (isPrime) prime.push_back(i);
    }

    lenJ = prime.size();
     
    while (cin >> n) {
        counter = 1;

        if (n < 2) counter = 0;
         
        for (i = 3; i <= n; i += 2) {
            isPrime = true;

            k = sqrt(i) + 1;
            for (j = 0; j < lenJ; j++) {
                if (k <= prime[j]) break;

                if (i % prime[j] == 0) {
                    isPrime = false;

                    break;
                }
            }

            if (isPrime) counter++;
        }
         
        cout << counter << endl;
    }
 
    return 0;
}

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

using namespace std;
#define MAX_NUM 999999


void do_calc(int *numPrime){
  for(int i=2;i<=MAX_NUM;i++){
    bool flag = false;

    for(int j=2;j<=sqrt(i);j++){
      if(i%j==0){
	flag = true;
	break;
      }
    }
      
    if(flag){
      numPrime[i] = numPrime[i-1];
      continue;
    }else{
      numPrime[i] = numPrime[i-1] + 1;
    }
  }
}
  


int main(){
  int n;
  int numPrime[MAX_NUM];

  do_calc(numPrime);
  while(cin >> n){
    cout << numPrime[n] << endl;
  }
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#define MAX 1000000
typedef long long int ll;

using namespace std;

bool isprime[MAX];
int prime[MAX];

void sieve()
{
    isprime[1]=1;
    for(int i=2;i<=sqrt(MAX);i++){
        if(!isprime[i]){
            for(int j=i*i;j<=MAX;j+=i){
                isprime[j]=true;
            }
        }
    }
    int count=0;
    for(int k=1;k<=MAX;k++){
        if(!isprime[k])prime[k]=++count;
        else prime[k]=count;
    }
}

int main()
{
    sieve();
    int n;
    while(scanf("%d",&n)==1){
        printf("%d\n",prime[n]);
    }
    return 0;
}

C++: #include <iostream>
#include <math.h>

int prime[1000000];


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


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  return 0;
}

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

int main()
{
  bool is_prime[1000000];fill(is_prime,is_prime+1000000,true);
  int count_prime[1000000];fill(count_prime,count_prime+1000000,0);
  is_prime[0]=false,is_prime[1]=false;
  for(int i=2;i<1000000;i++)
  {
    count_prime[i]=count_prime[i-1]+is_prime[i];
    if(!is_prime[i])continue;
    for(int j=i*2;j<1000000;j+=i)is_prime[j]=false;
  }
  int n;
  while(cin>>n)printf("%d\n",count_prime[n]);
}

C++: #include <iostream>

using namespace std;

int main(){
	int n, x;
	while(cin >> n){
		int x = 0;
		int sum;
	
		for(int i = 1;i <= n;i++){
			sum = 0;
			for(int j = 1; j <= i; j++){
				if( i % j == 0) sum += j;{
					if(sum == i + 1) x++;
				}
			}
		}
		
		cout << x << endl;
	}
	
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;

	while( scanf("%d" , &num) != EOF ){	
		p[0] = false;
		p[1] = false;
		for(int i=2 ; i<=MAX ; i++){
			p[i] = true;
		}
		answer = 0;

		for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
			if(p[i]==1){
				for(int j=i*2; j<=MAX; j=j+i){
					p[j] = false;
				}
			}
		}

		for(int i=0; i<=num; i++){
			if(p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
}

C++: #include <iostream>
#include <string>
#include <vector>

#include <math.h>

using namespace std;

static inline bool judge_prime(const int num) {
	if (num < 2) {
		return false;
	}
	else if (num == 2) {
		return true;
	}
	else if (num % 2 == 0) {
		return false;
	}
	else if (num == 3) {
		return true;
	}

	if (num % 3 == 0) {
		return false;
	}

	if(num % 6 != 1 && num % 6 != 5) {
		return false;
	}

	const double sqrtnum = sqrt(num);
	for(int i = 5; i <= sqrtnum; i += 6) {
		if(num % i == 0) {
			return false;
		}
		if (num % (i + 2) == 0) {
			return false;
		}
	}
	return true;
}

static int count_prime(const int input) {
	int counter_prime = 0;

	for (int i = input; 1 < i; i --) {
		if (judge_prime(i)) {
			counter_prime ++;
		}
	}
	return counter_prime;
}

int main() {
	int input;
	while(cin >> input) {
		cout << count_prime(input) << endl;
	}
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int n, cnt;	
	while(cin >> n){
		bool prime[n];
		prime[n] = {false};
		prime[1] = true;
		
		// ??¨??????????????????????????????
		for(int j = 2; j*j <= n; j++){
			if(prime[j] == false){
				for(int k = j; k*j <= n; k++){
					prime[j*k] = true;
				}
			}
		}
		cnt = 0;
		for(int i = 1; i <= n; i++){
			if(prime[i] == false) cnt++;
		}
		
		cout << cnt << endl;
	}
}

C++: #include<iostream>
#define N 999999
#define FOR(i,a,b) for( int i = ( a ); i < ( b ); i++ )
#define WHILE(n) while( std::cin >> n )
int p[(N+1)/2];int m[N+1];int mk();int main(){int n;p[0]=2;m[1]=0;m[2]=1;mk();WHILE(n){cout<<m[n]<<i'\n';}return 0;}int mk(){int i,j,e=1;REP(i,3,N_MAX){for(j=0;p[j]*p[j]<=i;j++){if(i%p[j]==0){goto tag;}}p[e]=i;e++;tag:m[i]=e;}}

C++: #include<cstdio>
int sosu[1000000]={};
bool f[1000000]={false};
int main(){
  sosu[2] = 1;
  for(int i=3;i<=999999;i+=2){
    if(!f[i]){
      f[i] = true;
      if(i >= 1000) continue;
      for(int j=i*i;j<=999999;j+=i) f[j] = true;
      sosu[i] = 1;
    }
    sosu[i] += sosu[i-1];
    sosu[i+1] += sosu[i];
  }
  int n;
  while(scanf("%d",&n)!=EOF) printf("%d\n",sosu[n]);
  return(0);
}