Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		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
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <numeric>
#include <functional>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cctype>
#include <climits>
#include <fstream>
#include <bitset>
#include <time.h>
#include <assert.h>
#include <random>

#define LL long long
#define VI vector<int>
#define VL vector<long long>
#define FOR(i,a,b) for(int i= (a); i<((int)b); ++i)
#define RFOR(i,a) for(int i=(a); i >= 0; --i)
#define FOE(i,a) for(auto i : a)
#define ALL(c) (c).begin(), (c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v,x) (std::find(v.begin(), v.end(), x) != v.end())
#define BIT(n) (1LL<<(n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
#define EPS 1e-14


using namespace std;

// nまでの素数のリストを作成(nを含む) O(N log long N)
vector<int> make_prime_list(int n) {
    vector<bool> is_prime(n + 1, true);
    is_prime[0] = false;
    is_prime[1] = false;

    vector<int> prime_list;
    for (int i = 2; i < n + 1; ++i) {
        if (!is_prime[i]) { continue; }
        prime_list.emplace_back(i);

        for (int j = i; j < n + 1; j += i) {
            is_prime[j] = false;
        }
    }
    return prime_list;
}

int main(int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    vector<int> prime_list = make_prime_list(1000100);

    int n;
    while(cin >> n) {
        int ans = 0;
        for(int i = 0;;++i)  {
            if(prime_list[i] <= n){
                ans++;
            }
            else {
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}

C++: #include<cstdio>
using namespace std;
bool prime[1000000];
#define max 1000000
int main(){
	prime[1] = true;
	for(int i = 2; i < max; i++){
		if(!prime[i]){
			for(int j = i * i; j < max; j+=i){
				prime[j] = true;
			}
		}
	}
	int n;
	while(scanf("%d",&n) != EOF){
		int ans = 0;
		for(int i = 1; i <= n; i++){
			if(!prime[i])ans++;
		}
		printf("%d\n",ans);
	}
	return 0;
}

C++: #include<iostream>
#include<iomanip>
#include<algorithm>
#include<cctype>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;

#define MAX 1000000

static bool gosei[MAX];

void b(){
	for(int i=2;gosei[i]==false&&i<MAX;i++)
		for(int j=2,k;(k=i*j)<MAX;j++)
			gosei[k]=true;
}

int c(int n){
	int cnt=0;
	for(int i=2;i<=n;i++)
		if(!(gosei[i]))cnt++;
	return cnt;
}

int main() {
	b();
	int n;
	while(cin>>n)
		cout<<c(n)<<endl;
	return 0;
}

C++: #include<cstdio>
int main(){
    int n;
    while(scanf("%d",&n)!=EOF){
        int x=2;
        for(int j=3;j<n;j+=2){
            bool a=true;
            for(int i=3;i*i<n;i+=2){
                if(j%i==0){
                    a=false;
                }
            }
            if(a)x++;
        }

        printf("%d\n",x);
    }

    return 0;
}

C++: #include <iostream>

int main() {
	int n;

	/**
	 * 0: No data
	 * 1: Prime number
	 * 2: Non prime number
	 */
	int db[1000000] = {2, 2, 1, 1};

	while (std::cin >> n) {
		int primes = 0; // n以下の素数の数
		int now;

		/* dbを走査 */
		loop:
		for (int i = 0; i <= n; i++)
		switch (db[i]) {
			case 1:
				primes++;
				break;
			case 0:
				now = i;
				goto next_phase;
		}

next_phase:
	/* 足りてなければ必要なだけごにょごにょ */
		for (int j = now; j <= n; j++) {
			bool flag = false; // はずれの目印
			for (int k = 2; k < j; k++)
				if (!(j % k)) {
					flag = true;
					break;
				}
			if (!flag) {
				db[j] = 1;
				primes++;
			} else
				db[j] = 2;
		}
		std::cout << primes << std::endl;
	}
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,sum;
    int b[999999];
    b[0]=0;
    for(int i=1;i<999999;i++){
        b[i]=prime(i);
    }
    while ( cin >> a){
        sum =0;
        for (int i=0;i<a;i++){
            sum +=b[i];
        }
        cout << sum-1 << endl;
    }
}


int prime(int x){
    if(x==2 || x==3 || x==5 || x==7)
        return 1;
    if(x%2==0 || x%3==0)
        return 0;
    for (int i=5;i<=sqrt(x)+1;i+=6){
        if(x%i==0 || x%(i+2)==0)
            return 0;
    }
    return 1;
}

C++: #include<cstdio>
int solve(int n){
	for(int i=2;i*i<=n;i++){
		if(n % i == 0){
			return 0;
		}
	}
	return 1;
}

int main(){
	int n;
	while(scanf("%d",&n) != EOF){
		int cnt = 0;
		for(int i=2;i<=n;i++){
			cnt += solve(i);
		}
		printf("%d\n",cnt);
	}
	return 0;
}

C++: #include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;

bool isprime (int n){

	if (n == 0 || n == 1){
		return false;
	}else if (n == 2){
		return true;
	}else if (n % 2 == 0){
		return false;
	} // end if
	
	for (int i = 3; i <= sqrt(n); i+= 2){
		if (n % i == 0){
			return false;
		} // end if
	} // end for
		
	return true;
}

int main()
{
	
//	cut here before submit 
//	freopen("testcase.prime", "r", stdin);
	int res = 0;
	string str = "";
	int n;

	getline (cin, str );
	stringstream ssn(str);
	ssn >> n;
	vector <int> prime(n+1, 0);

	int i;
	int count = 1;
	prime[2] = count;

	for (i = 3; i <= n; i += 2){
		if (isprime(i)){
			++count;
		} // end if
		prime[i] = count;
	} // end for
	res = prime[n];

	cout << res << endl; 

	return 0;
}

C++: #pragma  warning (disable:4996)
#include<iostream>
#include<cstdio>
#include<queue>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define MAX 1000000
using namespace std;
int amount[MAX];
int vis[MAX];
int prime[MAX];
int main(){
	memset(vis, 0, sizeof(vis));
	memset(prime, 0, sizeof(prime));
	prime[0] = prime[1] = 0;
	
	for (int i = 2; i <= MAX; i++){
		if (!vis[i]){

			prime[i] = 1;
			for (int j = i + i; j <= MAX; j += i){
				vis[j] = 1;
				prime[j] = 0;

			}
		}
	}
	int sum = 0;
	for (int i = 2; i <= MAX; i++){
			if (prime[i]){
				sum++;
			}
			amount[i] = sum;
		}

	int n;
	cin >> n;
		cout << amount[n]<< endl;
	return 0;
}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
  int n;
  while(cin>>n){
    vector<int> vi;
    vi.push_back(2);
    vi.push_back(3);
    for(int i=5;i<=n;i+=2){
      for(int j=3;j<=i;j+=2){
	if(i==j)
	  vi.push_back(i);
	if(i%j==0)
	  break;
      }
    }
    cout<<vi.size()<<endl;
  }
  return 0;
}

C++: 
#include <iostream>

using namespace std;

int main(int argc, char* argv[])
{
	int n, count,k;

	while(cin >> n){
		count = 1;
		k = 0;

		for(int i = 3; i <= n; i += 2){
			for(int j = 3; j <= sqrt((double)i); j += 2)
			{
				if(i%j == 0){
					k = 1;
					break;
				}
			}
			if(k == 0){
				count++;
			}
		}
		cout << count << endl;
	}

	return 0;
}