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 <iostream>
#include <vector>

typedef unsigned int Int;

Int sqrt_prm(const Int& target, Int x = 0) {
	while (x*x < target) {
		x++;
	}
	return x;
}

int main() {
	while (not std::cin.eof()) {
		Int target;
		std::cin >> target;

		std::vector<Int> primes = {};
		Int sqrt = 1;
		for (Int n = 3; n <= target; n+=2) {
			bool flag = true;

			sqrt = sqrt_prm(n, sqrt);
			for (auto&& p = primes.begin(); not(*p > sqrt or p == primes.end()); p++) {
				if (n % *p == 0) {
					flag = false;
					break;
				}
			}

			if (flag) {
				primes.push_back(n);
			}
		}

		std::cout << primes.size() + (target >= 2 ? 1 : 0) << std::endl;
	}
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
int main(){
	int n,cnt=0,ans,sosu[100000]={0};
	for(int i=2;i<100000;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0)flag=false;
		}
		if(flag){
		sosu[cnt]=i;
		cnt++;
		}
	}
	while(cin>>n){
	ans=0,cnt=0;
	for(int i=2;i<=n;i++){
		if(sosu[cnt]==i){
			cnt++;
			ans++;
		}
	}
	cout<<ans<<endl;
	}
    return 0;
}

C++: #include<iostream>
#include<cstdio>
#include <cstring>
using namespace std;
int main()
{
	    int n;
		bool a[1000001]; 
		memset(a,0,sizeof(a));
for(int i=2;i*i<=n;i++)
		{
			if(a[i]==false)
				for(int j=i*2;j<=n;j+=i)
					a[j]=true;
		}
	while(cin>>n)
	{
		int count=0;
	
		
		for(int k=2;k<=n;k++)
		{
			if(!a[k])
			count++;
		}
		cout<<count<<endl;
		
	}
	return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <numeric>
using namespace std;
#define OVER_SIX_DIGITS 1000000

int prime[OVER_SIX_DIGITS];

void make_prime(void) {
    for(int r = 0; r < OVER_SIX_DIGITS; r++) prime[r] = 1;
    prime[0] = prime[1] = 0;
    
    for(int r = 2; r < OVER_SIX_DIGITS; r++) {
        if(prime[r]) {
            for(int c = 2 * r; c < OVER_SIX_DIGITS; c += r) prime[c] = 0;
        }
    }
    //累積和配列を作成
    for(int r = 1; r < OVER_SIX_DIGITS; r++) prime[r] += prime[r - 1];
}

int main(void) {
    int n;
    make_prime();
    while(cin >> n) {
        cout << prime[n];
    }
    return(0);
}

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

int dp[1000000] = {};

int is_prime(int n) {
  if (n==1) {
    return 0;
  }
  for (int i=2; i*i<=n; i++) {
    if (n % i == 0) {
      return 0;
    }
  }
  return 1;
}

int main() {
  int n;
  for (int i=2; i<= 1000000; i++) {
    if (is_prime(i)) {
      dp[i] = dp[i-1] + 1;
    }
    else {
      dp[i] = dp[i-1];
    }
  }
   
  while(cin>>n) {
    cout << dp[n] << endl;
  }
}

C++: #include<iostream>
#include<iomanip>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
#include<string>
#include<cstring>
#include <sstream>
using namespace std;
int main(void){
    int n,ans,i;
    while(cin >> n){
        ans = 0;
        if(n < 2){
            cout << 0;
            continue;
        }else if(n == 2){
            cout << 1;
        }else{
            ans++;
        }
        for(i = 3; i <= n; i += 2){
            if(ceil(sqrti) == floor(sqrti)){
                continue;
            }
            ans++;
        }
        cout << ans << endl;
    }
    return 0;
}

C++: #include <iostream>
#define _USE_MATH_DEFINES
#include <math.h>
#define MAX_N 100000

void q9() {
	bool IsPrime[MAX_N];
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for (int i = 0; i < sqrt(MAX_N); i++) {
		if (!IsPrime[i]) continue;
		for (int j = i * 2; j < MAX_N; j += i) {
			IsPrime[j] = false;
		}
	}

	int NofP[MAX_N];
	NofP[0] = 0;
	for (int i = 1; i < MAX_N; i++) {
		NofP[i] = NofP[i - 1] + IsPrime[i];
	}

	int n;
	for (; cin >> n;) {
		cout << NofP[n] << endl;
	}
}

int main() {
	q9();
	return 0;
}

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

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

int main(){
    int N;
    bool isPrime[1001000];
    for(int i=0; i<=1000010; i++)isPrime[i]=true;
    isPrime[0]=false;
    isPrime[1]=false;
    for(int i=2; i<=1000010; i++){
        if(isPrime[i]){
            for(int j=2*i; j<=1000010; j+=i)isPrime[j]=false;
        }
    }
    while(cin>>N){
        int cnt=0;
        for(int i=2; i<=N; i++){
            if(isPrime[i])cnt++;
        }
        cout<<cnt<<endl;
    }
}

C++: #include<iostream>
#include<stdio.h>
using namespace std;
int prime[1000005];
bool is_prime[1000005];
int sieve(int n) {
	int p = 0;
	for (int i = 0;i <= n;i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2;i <= n;i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i;j <= n;j += i)is_prime[j] = false;
		}
	}
	return p;
}


int main()
{
	int n;
	int f = 0;
	
	while (scanf("%d", &n)) {
		if (f == 29) break;
		printf("%d\n", sieve(n));
		f++;
		
		
	}
	
	


	return 0;
}

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

int pn[1000002];

int main(){
int n, Count;
cin.tie(0);
while(scanf("%d",&n)!=EOF){
Count=0;
memset(pn,0,n);
pn[0]=pn[1]=1;
for(int i=2;i<=n;i++) if(!pn[i]) for(int j=1;i*j<=n;j++) pn[i*j]=1;
Count=count(pn,pn+n,0);
cout<<Count<<endl;
}
return 0;
}

C++: #include <iostream>
#include <cstdio>
#include <cstdlib>
#include <map>

using namespace std;

bool prime(int p){
	if ((p==0)||(p==1)){return false;}
	else if(p==2){return true;}
	else{
		for(int i=2; i*i<=p; i++){
			if(p%i == 0){return false;}
		}
	}
	return true;
}

int main()
{
	int n;
	map<int,bool> p;

	for(int i=0; i<1000000; i++){
		if(prime(i)){ p[i]=true;}
	}

	while(cin >> n){
		int count = 0;
		if(n>=2){count++;}
		for(int i=1; i<n+1; i=i+2){
			if(p[i]){count++;}
		}

		cout << count << endl;
	}
}

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

int main(void){
	long n;
	int a;
	while(scanf("%d", &n) != EOF){
		vector<bool>p;
		for(int i = 0; i <= n; i++) p.push_back(true);
		p[0] = false;
		p[1] = false;
		for(int i = 2; i < sqrt(n)+1; i++){
			if(p[i]){
				for(int j = 0; i*(j+2) <= n; j++){
					p[i*(j+2)] = false;
				}
			}
		}
		int count = 0;
		for(int i = 2; i <= n; i++){
			if(p[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <stdint.h>
using namespace std;

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

int main()
{
  for (int n; cin >> n; ) {
    int ans = 0;
    for (int i = 2; i <= n; i++)
      if (is_prime(i))
        ans++;
    cout << ans << endl;
  }

  return 0;
}

C++: #include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int sum[1000005];
bool shai[1000005];
void dabiao(){
	for(int i=2;i<=1000000;i++){
		sum[i]=sum[i-1];
		if(!shai[i]){
			for(int j=2*i;j<=1000000;j+=i)
				shai[j]=1;
			sum[i]++;
		}
	}
}
int main()
{
	dabiao();
	int n;
	while(scanf("%d",&n)==1){
		printf("%d\n",sum[n]);
	}
}