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 <cmath>
#include <cstdio>
#include <map>

bool fermat_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        return (static_cast<int>(std::pow(2, n - 1)) % n) == 1;
    }
}

bool prime_test(int n) {
    if (n < 2) {
        return false;
    } else if (n == 2) {
        return true;
    } else {
        for (int i = 3; i < static_cast<int>(std::sqrt(n)); i += 2) {
            if ((n %= i) == 0) {
                return false;
            }
        }
    }
    return true;
}

int main() {
    std::map<int, int> m;
    int n;
    while (~scanf("%d", &n)) {
        for (int i = 2; i <= n; ++i) {
            if (m.count(i) > 0)
                continue;

            m[i] = m[i - 1] + (fermat_test(i) && prime_test(i));
        }
        printf("%d\n", m[n]);
    }
}

C++: #include <iostream>
#include <cmath>
#include <algorithm>
#include <map>
#include <string>
#include <vector>
#define FOR(i, a, b)  for(int i=a; i<b; ++i)
#define rFOR(i, a, b) for(int i=a-1; i>=b; --i)
#define REP(i, n) for(int i=0; i<n; ++i)
#define rREP(i, n) for(int i=n-1; i>=0; --i)
#define all(a)  a.begin(), a.end()
#define MAXNUM 1000000
using namespace std;

int num[MAXNUM]={0};

int main(){
  int n;
  FOR(i, 2, (MAXNUM)/2){
    num[2*i]=1;
  }
  while(cin >> n){
    int ans=0;
    for(int i = 3; i<=n; i+=2){
      bool isPrimeN = true;
      if(num[i]!=0) continue;
      for(int j=3; j<=floor(sqrt(i)); j++){
        if(i%j==0){
          isPrimeN = false;
          break;
        }
      }
      if(isPrimeN){
        for(int j=2; j<=n; j++){
          if(j*i > n) break;
          num[j*i]=1;
        }
      }
    }
    FOR(i, 2, n+1){
      if(num[i]==0){
        ans++;
      }
    }
    cout << ans << endl;;
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;


int main(){
    int n, ans, cnt, prime;

    while(cin >> n){
      prime = 1;
      if(n == 1) cout << 0 << endl;
      if(n == 2) cout << 1 << endl;
      if(n == 3) cout << 2 << endl;

      if(n >= 4){
      for(int i=3; i <= n; i++){
        cnt = 0;
        for(int j=3; j <= sqrt(i); j += 2){
          if(i%j == 0) cnt++;
        }
        if(cnt == 0  && i%2 != 0) prime++;
      }
      cout << prime << endl;
    }
    }
    return 0;
}

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

#define MAX 1000000 

bool prime_table[MAX];
int head;

int main(){
	int n, i, j;
	int result;
	// make table
	for (i = 0; i < MAX; i++) {
		if(i==0||i==1){
			prime_table[i] = false;
		}else{
			prime_table[i] = true;
		}
	}
	// find prime
	for (i = 2; i < MAX; i++) {
		if(prime_table[i]){
			for (j = i+i; j < MAX; j+=i) {
				prime_table[j] = false;
			}
		}
	}
	
	while(cin >> n){
		result = 0;
		for (i = 0; i <= n; i++) {
			if(prime_table[i])
				result++;
		}
		cout << result << endl;
	}
	return 0;
}

C++: //36
#include<iostream>
 
using namespace std;
 
int main(){
  static bool cmp[1000000]={true};
  static int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;cin>>n;n++){
    cout<<npr[n]<<endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <map>
#include <vector>
#include <queue>
#define LL long long
#define PII pair<int, int>
using namespace std;
const int MAXN = 1000000;

int sum[MAXN+5];

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    // freopen("in.txt", "r", stdin);
    // freopen("out.txt", "w", stdout);
    sum[1] = 0;
    for (int i = 2; i <= MAXN; i++) {
        if (sum[i] == 0) {
            for (int j = i + i; j <= MAXN; j += i) {
                sum[j] = 1;
            }
        }
        sum[i] = sum[i - 1] + !sum[i];
    }

    int N;
    while (cin >> N) {
        cout << sum[N] << "\n";
    }
}

C++: #include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#define rep(i,a,n) for(int i=a;i<n;i++)
using namespace std;

int main(void){
	int i,j,k,n,a=1;
	cin >> n;
	if(n==1){
		cout << "0\n";
		return 0;
	}
	for(i=3;i<=n;i+=2){
		k=0;
		for(j=3;j<=sqrt(i);j+=2){
			if(i%j==0){
				k=1;
				break;
			}
		}

		if(k==0) a++;
	}

	printf("%d\n",a);
	return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	bool a[1000000];
	for(int abc=2;abc<=999999;abc++){
		a[abc]=true;
	}
	for(int abc=2;abc<=999999;abc++){
		if(a[abc]==true){
			for(int ab=abc*2;ab<=999999;ab+=abc){
				a[ab]=false;
			}
		}
	}
	int ad;
	while(cin>>ad){
		int ansa=0;
		for(int abc=2;abc<=ad;abc++){
			if(a[abc]==true){
				ansa++;
			}
		}
		cout<<ansa<<endl;
	}
	return 0;
}

C++: #include <iostream>

using namespace std;
int main()
{
    long long n;
    long long prime = 0;

    cin >> n;
    
    for(int x=1; x<=n; x++)
    {
            int counter = 0;
            for(int y=1; y<=x; y++)
            {
                    if(x%y==0)
                    counter++;
            }
            
            if(counter==2)
            {
                    cout << x << endl;
                    prime++;
            }
    }
    
    cout << prime << endl;
    
return 0;
}

C++: #include <cstdio>
 
int main(){
  bool cmp[1000000]={true};
  int npr[1000000];
  for(int i=2;i<1000000;i++){
    if(!cmp[i]){
      for(int j=2;j*i<1000000;j++){
    cmp[i*j]=true;
      }
    }
    npr[i]=npr[i-1]+!cmp[i];
  }
  for(int n;scanf("%d", &n);n++){
  	printf("%d\n", npr[n]);
  }
  return 0;
}

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

int main(){

  int n;

  while(cin>>n){

	int cnt=0;
	
	if(n <= 1){
	  cout<<0<<endl;
	  continue;
	}

	else
	  cnt++;
	
	for(int i=3;i<=n;i+=2){
	  int f = true;
	  for(int j=2;j<i;j++){
		if(i%j==0){
		  f = false;
		  break;
		}
	  }
	  if(f == true)
		cnt++;
	}

	cout<<cnt<<endl;
	
  }

  return 0;
  
}

C++: #include <iostream>

bool Check(int);

int main(void)
{
    int input;
    int count;
    while(std::cin >> input){
        count = 0;
        for(int j=2;j <= input;++j){
            if(Check(j)){
                ++count;
            }
        }
        std::cout << count << std::endl;
    }
    return 0;
}
bool Check(int value)
{
    bool result = true;
    for(int i=value / 2;i >= 2;--i){
        if(value % i == 0){
            result = false;
            break;
        }
    }
    return result;
}