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:
		return true
	case num < 2 || num%2 == 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<iostream>
#include<algorithm>
#include<math.h>
using namespace std;
int n;
int main(){
	while(cin>>n){
		int sum=0;
		if(n<=10000){
			for(int i=2;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopa;
					}
				}
				sum++;
				loopa:;
			}
			cout<<sum<<endl;
		}
		else if(n<=100000){
			for(int i=10001;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopb;
					}
				}
				sum++;
				loopb:;
			}
			cout<<sum+1229<<endl;
		}
		else{
			for(int i=100001;i<=n;i++){
				for(int j=2;j<=sqrt(i);j++){
					if(i%j==0){
						goto loopc;
					}
				}
				sum++;
				loopc:;
			}
			cout<<sum+9592<<endl;
		}
	}
	return 0;
}

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

int main(){
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<vector>
using namespace std;
int main(){
	int n;
	vector<int> pri(1000000);
	for(int i=0;i<1000000;i++)
		pri[i]=1;
	pri[0]=0;
	pri[1]=0;
	for(int i=0;i*i<n;i++){
		if(pri[i]){
			for(int j=i*2;j<1000000;j+=i)
				pri[j]=0;
		}
	}
	
	
	while(cin>>n){
	int i=0,k=0;
	while(k<=n)
	if(pri[k++])
	i++;
	
		cout<<i<<endl;
	}
	return 0;
}

C++:  #include<iostream>
 #include<stdio.h>
 #include<string>
 #include<math.h>
 #include<iomanip>
 #include<algorithm>
 #include<string.h>
 #include<cctype>
 #include<map>
 #include<set>
 #include<vector>
 #include<sstream>
 
 using namespace std;
 
 int kk[10*10];
 
 bool isPrime(int x)
 {
   for(int i=2;i<=(int)(sqrt(x));i++) 
   {
     if(x%i==0) return false;        
   }    
   return true;
 }
 
 int main()
 {
   int n;
   while(cin>>n)
   {
      int count=0;
      for(int i=2;i<=n;i++) if(isPrime(i)) count++;
      cout<<count<<endl; 
   }
   //while(1);      
   return 0;    
 }

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

int a[1000000];

int sosuu(){
	a[0] = 0;
	a[1] = 0; 
	int k;
	for(int i = 2;i<1000000;i++){
		k = 0;
		a[i] = a[i - 1];
		for(int j=2;j<=sqrt(i);j++){
			if(i%j == 0){
				k++;
				break;
			}
		}
		if(k==0){
			a[i]++;
		}
	}
	return 0;

}

int main(){
	int n;
	sosuu();
	while (true)
	{
		cin >> n;
		if (cin.eof()) { break; }
		cout << a[n] << endl;
	}
	return 0;
}

C++: #include <iostream>
#include<stdio.h>
#include<string>
#include<map>
#include<vector>
#include<stdlib.h>
typedef long long ll;
using namespace std;
#define INF 100000000000
#include<algorithm>
#include<string.h>
bool num[1000000];
int main(){
    int n;
    while(cin >> n){
        memset(num,true,sizeof(num));
        num[0] = num[1] = false;
        for(int i = 2;i<=n;i++){
            if(num[i] == true){
                for(int j = 2*i;j<=n;j+=i){
                    num[j] = false;
                }
            }

        }
        int ans = 0;
        for(int i =2;i<=n;i++){
            if(num[i]){ans++;}
        }
        cout<<ans<<endl;
    }

}

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

using namespace std;

int HowManyPrimeNumbers1(const int);
int HowManyPrimeNumbers2(const int);
int MySqrt(const int);

int main(){
	int n;

	while(cin >> n){
		printf("%d\n",HowManyPrimeNumbers2(n));
	}

	return 0;
}

int HowManyPrimeNumbers1(const int n){
	int i,j,buf,cnt = 1;

	for(i=3;i<=n;i+=2){
		buf = (int)sqrt((double)i);

		for(j=3;j<=buf;j+=2){
			if((i % j) == 0){
				cnt--;
				break;
			}
		}

		cnt++;
	}

	return cnt;
}

int HowManyPrimeNumbers2(const int n){
	int i,j,cnt,root,rt;

	// 3 から n までの奇数の個数 + 1 を n に代入
	cnt = ((int)((((double)(n - 2)) / 2) + 0.5)) + 1;

	// 最大処理数を求める
	root = (int)sqrt((double)n);

	// a
	for(i=3;i<=root;i+=2){
		rt = MySqrt(i);
		for(j=3;j<=rt;j+=2){
			if((i % j) == 0){
				cnt += ((int)(n / i));
				break;
			}
		}
		cnt -= ((int)(n / i));
	}

	return n;
}

int MySqrt(const int i){
	int n;

	n = i - 1;

	return (int)(1 + (1 / 2) * (double)(i - 1) - (1 / 8) * (double)(i - 1) * (i - 1) + (1 / 16) * (double)(i - 1) * (i - 1) * (i - 1));
}

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

int main(){
	bool p[MAX+1];
	int n, ans;

	for(int i=0 ; i<=MAX ; i++){
		p[i] = (i<=1)? false : true ;
	}

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

	while( cin >> n ){		
		ans = 0;
		for(int i=0 ; i<=n ; i++){
			if(p[i]){
				ans++;
			}
		}
		cout << ans << endl;
	}
}

C++: #include <cstdio>
#define max_n 999999
#define INF 1000000
int prime[max_n];
bool is_prime[max_n+1];
int main(){
    for(int i=0; i<max_n; i++){
        prime[i] = INF;
        is_prime[i]=true;
    }
    int p = 0;
    is_prime[1]=false;
    is_prime[0]=false;
    for(int i=2;i<max_n;i++){
        if(is_prime[i]){
            prime[p++] = i;
            for(int j=2*i;j<max_n;j+=i)is_prime[j]=false;
        }
    }
    int n;
    while(scanf("%d",&n)!=EOF){
        //printf("%d\n",n);
        int ans = 0;
        for(int i =0; i<max_n; i++){
            if(prime[i]>n){
                ans = i;
                break;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

int main() {
  constexpr int max = 1000000;
  vector<bool> isPrime(max, true);
  isPrime[0] = isPrime[1] = false;
  for (int i = 2; i * i < max; i++) {
    if (isPrime[i]) {
      for (int j = i * 2; j < max; j += i) {
        isPrime[j] = false;
      }
    }
  }
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 0; i <= n; i++) {
      if (isPrime[i]) ans++;
    }
    cout << ans << endl;
  }
  return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <list>
#include <map>
#include <algorithm>
#include <stack>
#include <string>

using namespace std;


int main(){
	int n = 0;
	int count;
	bool flag = false;

	while(cin >> n){
		count = 1;
		for(int i = 3; i <= n; i += 2){
			for(int j = 3; j * j <= i; j += 2){
				if(i % j == 0){
					flag = true;
					break;
				}
			}
			if(flag != true){
				count++;
			}
			else{
				flag = false;
			}
		}
		cout << count << endl;
	}

	return 0;
}