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

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

int whether(int num);
int count(int num);

int main(){
	int n;
	int a;
	clock_t c, d;

	while(scanf("%d",&n) != EOF){
	scanf("%d",&n);
	a = count(n);
	printf("%d\n",a); 
}

	return 0;
}

int whether(int num){
	int s=sqrt(num);
	int i;
	for(i=3; i<=s; i+=2){ if(num%i==0) return 0; }

	return 1;
}

int count(int num){
	int a=1;
	int i;
	if(num <2){ return 0; }
	for(i=3; i<=num; i+=2){
		a += whether(i);
	}

	return a;
}

C++: #include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define repf(i, f, l) for(int i = f; i < (int)l; ++i)

#ifdef ONLINE_JUDGE
#define DEBUG false
#else
#define DEBUG true
#endif

#define pb emplace_back
#define lb lower_bound
#define ul unsigned long
#define ull unsigned long long
#define ll long long
#define INF 1000000007
#define MOD 1000000007
#define fs first
#define sd second

#define ALL(c) (c).begin(),(c).end()

#define DBG0(x)    {if(DEBUG){ cout << #x << ": " << x << "\t"; }}
#define DBG(x)     {if(DEBUG){DBG0(x); cout << endl;}}
#define DBG2(x, y) {if(DEBUG){DBG0(x); DBG(y);}}
#define DBG3(x, y, z) {if(DEBUG){DBG0(x); DBG2(y, z);}}
#define DBG4(w, x, y, z) {if(DEBUG){DBG0(w); DBG3(x, y, z);}}

template <class T>
ostream& operator<<(ostream& os, vector<T> xs){ for(T x: xs) os << x << ' '; return os; }
template <class S, class T>
ostream& operator<<(ostream& os, pair<S,T> st){ os << "(" << st.first << "," << st.second <<")"; return os; }

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<ul> vul;
typedef vector<ull> vull;
typedef vector<bool> vbl;
typedef pair<int, int> pii;

const int PN = 2100000;
vint ps;
vector<bool> eratos;
void init_primes(void){
    eratos = vector<bool>(PN, false);
    ps.clear();
    for(int i = 2; i < PN; ++i){
        if(!eratos[i]){
            ps.pb(i);
            for(int j = i; j < PN; j += i)
                eratos[j] = true;
        }
    }
    return;
}
int main(void){
    init_primes();
    int n;
    while(cin >> n){
        if(n < 2){
            cout << 0 << endl;
            continue;
        }
        int l = 0, r = ps.size() - 1;
        while(r - l > 1){
            int med = (l + r) / 2;
            if(ps[med] <= n) l = med;
            else r = med;
        }
        cout << l + 1 << endl;
    }
    return 0;
}

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

const int MAX_N = 1000000;

int main(){
    vector<bool> is_prime(MAX_N, true);
    vector<int> primes;
    for(int i=2;i<MAX_N;i++){
        if(is_prime[i]){
            primes.push_back(i);
            for(int j=i*i;j<MAX_N;j+=i){
                is_prime[j] = false;
            }
        }
    }

    int n;
    while(cin >> n){
        int ans = upper_bound(primes.begin(), primes.end(), n) - primes.begin();
        cout << ans << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <math.h>
#define MAX 1000000
using namespace std;

int main(){
	int n;
	int *prime,i,j;
	prime = new int[80000];
	int *answer = new int[MAX];
	int count;
	bool flag;

	count = 1;
	answer[1] = 0;
	answer[2] = 1;
	for(i = 3; i <= 1000000; i+=2){
		flag = true;
		for(j = 0; j < count; j++){
			if(i % prime[j] == 0){
				flag = false;
				break;
			}
			if(prime[j] * prime[j] > i) break;
		}
		if(flag == true){
			prime[count++] = i;
		}
		answer[i] = count;
		answer[i+1] = count;
	}
	while((cin >> n)!= NULL){
		cout << answer[n] << endl;
	}
	return 0;
}

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

//素数かどうか判定する関数
bool judge( int x )
{
    int count = 0;

    for( int i = 1; i <= x; i += 2 )
    {
        if( x % i == 0)
            count++;
    }

    if( count == 2 )
        return true;
    else
        return false;
}

int main()
{
    int n;

    while( cin >> n )                           //2が素数であることを予め考慮
    {
        int count = 1;                          //coutは素数の数なので、1

        if( n <= 1 )                            //nが1以下なら素数の数は0
        {
            count = 0;
        }

        for( int i = 3; i <= n; i += 2 )        //3以上の自然数について、奇数のみ素数判定を行う
        {
            if( judge(i) )
                count++;
        }

        cout << count << endl;
    }

    return 0;
}

C++: #include <iostream>
#include <string>
#include <stack>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <vector>

using namespace std;
int sieve(int n);
int prime[1000000];
bool is_prime[1000000];

int main()
{

	int p = 0;
	for (int i = 0; i <= 999999; i++) {
		is_prime[i] = true;
	}
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i <= 999999; i++) {
		if (is_prime[i]) {
			prime[p++] = i;
			for (int j = 2 * i; j <= 999999; j += i) {
				is_prime[j] = false;
			}
		}
	}
	int n;
	while (scanf_s("%d", &n) != EOF) {
		int i = 0;
		while (prime[i] <= n) {
			i++;
		}
		cout << i << endl;
	}
}

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

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

int main() {
  int n;
  while(cin >> n) {
    int num = 0;
    for(int i = 2; i <= n; ++i) num += isPrime(i);
    cout << num << endl;
  }
  return 0;
}

C++: #include <cstdio>
#include <iostream>
#define M 1000000

using namespace std;

int main() {

	int c, n;
	bool x[M];

	for(int i=2; i<=M; i++) {
		x[i]=false;
	}
	for(int i=2; i<1000; i++) {
		if(x[i])
			continue;
		for(int j=i*2; j<M; j+=i) {
			if(!x[j])
				x[j]=true;
		}
	}

	while(scanf("%d", &n)!=EOF) {
		c=0;
		for(int i=2; i<=n; i++) {
			if(!x[i])
				c++;
		}
		cout << c << endl;
	}
	

	return 0;

}

C++: #include<iostream>
using namespace std;
int main()
{
    int i=2, j=2, n;
    
    cout<<"Enter a number to print Prime Number: ";
    cin>>n;
    
    cout<<i<<" ";
    
    for(i=2; i<=n; i++)
             for(j=2; j<i; j++)
             {
                      if(i%j == 0)
                      break;
                      else if(i==j+1)
                      cout<<i<<" ";
             }
             
    cout<<endl;
    
    system("pause");
    return 0;
}

C++: #include <iostream>

#define MAX_SIZE 1000000

using namespace std;

void sieve(bool *a) {
    a[0] = a[1] = true;
    
    for(int i = 2;i < MAX_SIZE;i++) {
        if(!a[i]) {
            for(int j = 2;(i * j) < MAX_SIZE;j++) {
                a[i * j] = true;
            }
        }
    }
}

int main() {
    bool not_prime[MAX_SIZE] = { false };
    
    sieve(not_prime);
    
    int n, cnt;
    
    while(cin >> n) {
        cnt = 0;
        
        for(int i = 0;i <= n;i++) {
            if(!not_prime[i]) {
                cnt++;
            }
        }
        
        cout << cnt << endl;
    }
    
    return 0;
}

C++: 
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <stack>
#include <cctype>
#include <complex>
#include <vector>
#include <algorithm>

using namespace std;


int f(int a){
	if(a==1) return 0;
	for(int i=2;i<=sqrt((double)a);i++){
		if(!(a%i)){
			return 0;
		}
	}
	return 1;
}
bool solve(){
	int n;
	while(cin>>n){
		int cnt=0;
		for(int j=2;j<=n;j++){
			cnt += f(j);
		}	
		cout<< cnt<< endl;
	}
	
	return true;
}

int main(){
	cout.setf(ios::fixed);
	cout.precision(10);
	solve();

	return 0;
}