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++: 
//  test.cpp

#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>

using namespace std;


int main(){
    long int j,s[1000000]={0},d=1,i,n,k;
    
    s[0]=s[1]=1;
    
    for(i=2;i<1000000;i++){
        if(s[i]==0){
            
            for(j=2;j*j<=i;j+=2){
                if(i%j==0)
                    break;
                if(j==2)
                    j=1;
            }
            
            
            if(j*j>i){
                d++;
                if(i<1000){
                    for(k=2;k*i<1000000;k++){
                        s[k*i]=-1;
                    }
                }
            }
        }
        s[i] = d;
    }
    
    while(EOF != scanf("%ld",&n)){
        printf("%ld\n",s[n]-1);
    }
    
    
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL << 30)
#define LLINF (1LL << 60)
#define PI 3.14159265359
#define EPS 1e-12
#define int ll

signed main(void) {
  int n;
  while (cin >> n) {
    int ret = 0;
    for (int i = 2; i <= n; ++i) {
      bool flag = true;
      for (int j = 2; j * j <= i; ++j) {
        if (i % j == 0)
          flag = false;
      }
      if (flag) {
        ret++;
      }
    }
    cout << ret << endl;
  }
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for (ll i=(a);i<(b);i++)
#define RFOR(i,a,b) for (ll i=(b)-1;i>=(a);i--)
#define REP(i,n) for (ll i=0;i<(n);i++)
#define RREP(i,n) for (ll i=(n)-1;i>=0;i--)
#define debug(x) cout<<#x<<": "<<x<<endl
#define pb push_back
#define ALL(a) (a).begin(),(a).end()

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
	EACH(x,vec) is >> x;
	return is;
}
template<typename T>
ostream& operator<<(ostream& os, vector<T>& vec) {
	REP(i,vec.size()) {
		if (i) os << " ";
		os << vec[i];
	}
	return os;
}
template<typename T>
ostream& operator<<(ostream& os, vector< vector<T> >& vec) {
	REP(i,vec.size()) {
		if (i) os << endl;
		os << vec[i];
	}
	return os;
}

bool isPrime[1000006];
ll cnt[1000007] = {0};
int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	fill(isPrime, isPrime+1000006, true);
	isPrime[0] = isPrime[1] = false;
	for (int i = 2; i <= 1000005; ++i) {
		for (int j = i*2; j <= 1000005; j += i) {
			isPrime[j] = false;
		}
	}
	REP(i, 1000006) {
		cnt[i+1] = cnt[i] + (isPrime[i] ? 1 : 0);
	}
	int N;
	while ( cin >> N ) {
		cout << cnt[N+1] << endl;
	}
}

C++: #define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;


int main()
{
	int i,j,n,flag,number=0;
	
	while(cin>>n){
		number=0;
	for(j=2;j<=n;j++){
		flag=0;
		for(i=2;i<j-1;i++)
		{
		if(j%i==0)flag=1;
		}
		if(flag!=1)number++;
		
	}
	cout<< number << endl;
	}
	//cout<< number << endl;
	return (0);
}

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i=3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			if(isprime(i)){
				c++;
			}
		}
		printf("%d\n",c);
	}
	return 0;
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt;

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

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

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

int a[999999];
int b[999999];

int prime(int x) {
	if (a[x] == 1) return 1;
	else if (a[x] == 2) return 0;
	for (int i = 2; i < sqrt(x) + 1; i++) {
		if (x%i == 0) {
			a[x] = 2;
			return 0;
		}
	}
	return a[x]=1;
}
int main(){
	int n;
	b[0] = 0;
	b[1] = 0;
	b[2] = 1;
	a[0] = 2;
	a[1] = 2;
	a[2] = 1;
	int count = 1;
	for (int i = 3; i <= 999999; i++) {
		if (prime(i))count++;
		b[i] = count;
	}
	while (scanf("%d", &n) != EOF){
		printf("%d\n", b[n]);
	}
	return 0;
}

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

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

#define MAX_N 1000000

int ans[MAX_N];

main(){
	ans[0] = 0;
	ans[1] = 0;
	for(int i=2; i<MAX_N; i++){
		ans[i] = ans[i-1] + isPrime(i);
	}
	
	int n;
	while(cin>>n){
		cout << ans[n] << endl;
	}
}

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

int main()
{
	bool is_prime[1000000];
	
	is_prime[0]=is_prime[1]=false;
	
	for(int i=2;i<1000000;i++){
		is_prime[i]=true;
	}
	
	for(int i=2;i*i<1000000;i++){
		if(is_prime[i]){
			for(int j=i*i;j<1000000;j+=i){
				is_prime[j]=false;
			}
		}
	}
	
	int n_prime[1000000];
	
	int cnt=0;
	for(int i=0;i<1000000;i++){
		if(is_prime[i]){
			cnt++;
		}
		
		n_prime[i]=cnt;
	}
	
	while(true){
		int n;
		cin>>n;
		if(cin.eof())
			break;
		
		cout<<n_prime[n]<<endl;
	}
	
	return 0;
}

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

#define MAXN 1000005

int a[MAXN];

void judgePrime()
{
    int m=sqrt(MAXN);
    memset(a,0,sizeof(a));
    for(int i=2; i<=m; i++)
    {
        if(!a[i])
        {
            for(int j=i*i; j<MAXN; j+=i)
                a[j]=1;
        }
    }
}

int main()
{
    judgePrime();
    int n;
    while(~scanf("%d",&n))
    {
        int cnt=0;
        for(int i=2; i<=n; i++)
        {
            if(!a[i])
                cnt++;
        }
        printf("%d\n",cnt);
    }
    return 0;
}

C++: #include <stdio.h>
#define MAX 1000000
int isPrime[MAX];
int main(){
int num;
int i, j;
int count;
// 配列の初期化
isPrime[0] = isPrime[1] = 0;
for(i = 2; i < MAX; i++){
isPrime[i] = 1;
}
// エラストテネスのふるい
for(i = 2; i * i < MAX; i++){
if(isPrime[i]){
// iの倍数は素数じゃないのでフラグ変更
for(j = 2 * i; j < MAX; j+=i){
isPrime[j] = 0;
}
}
}
while(scanf("%d", &num) != EOF){
count = 0;
while(num){
count += isPrime[num--];
}
printf("%d\n", count);
}
return 0;
}

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

int main() {
	int n,i,j,a=0,b=0;
	while (cin >> n) {
		if(n>=9) {
			for (i = 9; i <= n; i++) {
				a=0;
				for (j = 3; j <= n; j++) {
					if (i%j == 0) {
						a++;
						break;
					}
					j++;
					b += a;
				}
				i++;
			}
		}
		if (n == 2)cout << "1" << endl;
		else if (n == 3)cout << "2" << endl;
		else if (n == 5) cout << "3" << endl;
		else if (n == 7)cout << "4" << endl;
		else if (n % 2 == 0) cout << n / 2 - b - 1 << endl;
		else cout << (n + 1) / 2 - b - 1 << endl;
	}
	return 0;
}