Go: package main

import "fmt"

func main() {
	const MAX = 1000000
	prime := make([]int, MAX, MAX)
	check := make([]int, MAX, MAX)
	count := make([]int, MAX, MAX)

	prime[0] = 1
	prime[1] = 1

	// prime init
	for i := 2; i < MAX; i++ {
		if check[i] == 1 {
			continue
		}

		if prime[i] == 0 {
			for j := i * 2; j < MAX; j += i {
				check[j] = 1
				prime[j] = 1
			}
		}
	}

	for i := 2; i < MAX; i++ {
		cnt := 0

		if prime[i] == 0 {
			cnt = 1
		}

		count[i] = count[i-1] + cnt
	}

	for {
		var input int
		inputCount, _ := fmt.Scanf("%d", &input)
		if inputCount != 1 {
			break
		}

		fmt.Println(count[input])
	}
}

C++: #include<memory.h>
#include<cstdio>
const int maxn=100000;
int x;
bool isPrime[maxn];
void generateprime()
{

    memset(isPrime,true,sizeof(isPrime));
    for(int i=2;i<maxn;i++)
        for(int j=2;j*i<maxn;j++)
        isPrime[j*i]=false;
}

int main()
{
    generateprime();
    while(scanf(" %d",&x)!=EOF)
    {   int res=0;
        for(int i=2;i<=x;i++)
            if(isPrime[i])
            {
            res=res+1;}
        printf("%d\n",res);
    }
}

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

bool isPrime(unsigned int n) {
  unsigned int count=0;
  unsigned int max;
  count = 0;
  max = n;

  for(int i=2; i<max; i++) {
    if(n%i==0) return false;
    max = n/i;
  }
  return true;
}

int main() {
  unsigned int input;
  unsigned int count;
  unsigned int cum[500000]; // for odd numbers greater than or equal to 1

  count = 1; // For 2
  cum[0] = 0; // For 1
  cum[1] = 2; // For 3
  for(int i= 2; i<500000; i++) {
    if(isPrime(2*i+1)) {
      cum[i] = cum[i-1]+1;
      count++;
    } else {
      cum[i]=cum[i-1];
    }
  }

  while(cin >> input) {
    count = 0;
    if(input==2)
      cout << "1" << endl;
    else
      cout << cum[(int)(input-0.5)/2] << endl;
  }

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>

using namespace std;

vector<int>soe(int n);

int main(void)
{
	int num, pn;
	int count = 0;
	
	while(cin >> num){
		vector<int>test(num);
		test = soe(num);
		
		for(int i = 0; i < num; i++){
			if(test[i])
			count++;
		}
		cout << count <<endl;
	}
	return 0;
}

vector<int>soe(int n){
	vector<int>hyo(n);
	for(int i = 2; i < n; i++)
	hyo[i] = i;
	for(int i = 2; i*i < n; i++){
		if(hyo[i])
		for(int j = i*i; j < n; j += i){
			hyo[j] = 0;
		}
	}
	return hyo;
}

C++: #include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

int main()
{
    int prime_num[1000001];
    memset(prime_num, 0, 1000001);
    prime_num[2] = 1;
    int ans = 1;
    for(int i = 3; i <= 1000000; i++) {
        if(i % 2 == 0) { 
            prime_num[i] = prime_num[i-1];
            continue;
        }
        bool is_prime = true;
        for(int j = 3; j*j <= i; j++) {
            if(i % j == 0) {
                is_prime = false;
                break;
            }
        }
        if(is_prime) {
            prime_num[i] = prime_num[i-1] + 1;
        } else {
            prime_num[i] = prime_num[i-1];
        }
    }
    int n;
    while(cin >> n) {
        cout << prime_num[n] << endl;
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
	int a,j,o=0;
	bool n[1000000];
	for(int i=2;i<=99999;i++){
		n[i]=true;
	}
	n[0]=n[1]=false;
		for( j=2;j<=99999;j++){
			if(n[j]){
				for(int k=j*2;k<=99999;k+=j){
				n[k]=false;
				}
			}
		}
		while(cin>>a){
	for(int k=2;k<=a;k++) if(n[k]) o++;
	cout<<o<<endl;
	o=0;
		}
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <utility>
#include <string>
#include <math.h>
typedef unsigned long ul;

using namespace std;

int arr[1000000] = {0};

int main(){
	for(int i = 2; i < 999999; i++)arr[i] = 1;
	for(int i = 2; i*i < 999999; i++){
		for(int j = i*2; arr[i] == 1 && j <= 999999; j += i){
			arr[j] = 0;
		}
	}
	for(int i = 1; i <= 999999;i++)arr[i] += arr[i-1];

	int n;
	while(cin >> n){
		cout << arr[n] << endl;
	}
}

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=0;
    for(int i=2;i<=n;i++)if(prime[i])ans++;
        printf("%d\n",ans);
    }
}

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

int main(){
 int n,i,j,x,counter;
 while (cin >> n) {
  counter = 0;
  
  for (i = 1; i <= n; i++) {
    x = 0;
    
    for (j = 1; j <= i; j++) {
      if (i % j == 0) x++;
    }
    
    if (x == 2) counter++;
  }
  
  cout << counter << endl;
  
 }
 return 0;
}

C++: #include <iostream>
using namespace std;
int main(){
    int n,count=0;
    while(cin>>n){
        count=0;
        for(int a=2;a<=n;a++){
            for(int b=2;b<=a;b++){
                if(a==b)count++;
                if(a%b==0)break;
            }
        }
        cout<<count<<endl;
    }
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

_i64 _gcd(_i64 a, _i64 b) {
    return (max(a, b) % min(a, b) != 0 ? _gcd(min(a, b), max(a, b) % min(a, b)) : min(a, b));
}

int main() {
    {
        _time time(disable);
        _i64 n;
        vector<_i64> ans(1000000);
        ans[1] = 0; ans[2] = 1; ans[3] = 2; ans[4] = 2;
        for(_i64 i = 5; i < 1000000; i += 6) {
            for(_i64 j = 3; j <= sqrt(i) + DBL_EPSILON; j += 2) {
                if(i % j == 0) { ans[i] = ans[i - 1]; break; }
            }
            if(!ans[i]) { ans[i] = ans[i - 1] + 1; }
            ans[i + 1] = ans[i];
            for(_i64 j = 3; j <= sqrt(i + 2) + DBL_EPSILON; j += 2) {
                if((i + 2) % j == 0) { ans[i + 2] = ans[i + 1]; break; }
            }
            if(!ans[i + 2]) { ans[i + 2] = ans[i + 1] + 1; }
            ans[i + 3] = ans[i + 2];
            ans[i + 4] = ans[i + 3];
            ans[i + 5] = ans[i + 4];
        }
        while(cin >> n) { cout << ans[n] << endl; }
    }
    return 0;
}