Go: package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		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
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

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

template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void POSS(T condition){ if(condition) cout << "POSSIBLE" << endl; else cout << "IMPOSSIBLE" << endl; }
template<class T> inline void Poss(T condition){ if(condition) cout << "Possible" << endl; else cout << "Impossible" << endl; }
template<class T> inline void First(T condition){ if(condition) cout << "First" << endl; else cout << "Second" << endl; }
int character_count(string text, char character){ int ans = 0; for(int i = 0; i < text.size(); i++){ ans += (text[i] == character); } return ans; }
long power(long base, long exponent, long module){ if(exponent % 2){ return power(base, exponent - 1, module) * base % module; }else if(exponent){ long root_ans = power(base, exponent / 2, module); return root_ans * root_ans % module; }else{ return 1; }}
struct position{ int y, x; }; position move_pattern[4] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}}; // double euclidean(position first, position second){ return sqrt((second.x - first.x) * (second.x - first.x) + (second.y - first.y) * (second.y - first.y)); }
template<class itr, class func> void array_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += to_string(*i) + " "; } ans.pop_back(); cout << ans << endl; }
template<class itr, class func> void nint_output(itr start, itr goal, func out = [](itr x) { return x; } ){ string ans; for(auto i = start; i != goal; i++){ ans += string(out(*i)) + " "; } ans.pop_back(); cout << ans << endl; }
long gcd(long a, long b){ if(a && b){ return gcd(min(a, b), max(a, b) % min(a, b)); }else{ return a; }}
#define mod long(1e9 + 7)
#define all(x) (x).begin(), (x).end()
#define bitcount(n) __builtin_popcount(n)

int main(){
    int n;
    vector<int> prime_sieve(1e6, -1);
    for(int i = 2; i < 1e6; i++){
        if(prime_sieve[i] == -1){
            prime_sieve[i] = 1;
            for(int j = i * 2; j < 1e6; j += i){
                prime_sieve[j] = 0;
            }
        }
    }
    vector<int> cumulative_sum{0, 0};
    for(int i = 2; i < 1e6; i++){
        cumulative_sum.push_back(cumulative_sum.back() + prime_sieve[i]);
    }
    while(cin >> n){
        cout << cumulative_sum[n] << endl;
    }
}

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

int solve(int num){
	for(int i=2;i<num;i++)
		if(num%i==0) return 0;
	return 1;
}

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

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

int primes[78498], num_primes = 1;
int calculated = 2;
int count_pos(int n) {
	for (int i = 0; i < num_primes; i++) {
		if (primes[i] == n) {
			return i + 1;
		}
		else if (primes[i] > n) {
			return i;
		}
	}
	return num_primes;
}
int main() {
	primes[0] = 2;
	while (true) {
		int n;
		if (!scanf("%d", &n)) break;
		if (calculated+1 < n) {
			for (int i = calculated + 1; i < n + 1; i += 2) {
				bool is_prime = true;
				for (int w = 3; w < (int)(sqrt(i)) + 1; w += 2) {
					if (i%w == 0) {
						is_prime = false;
						break;
					}
				}
				if (is_prime) {
					primes[num_primes++] = i;
				}
			}
			calculated = n - (n % 2);
		}
		printf("%d\n", count_pos(n));
	}
}

C++: #include <stdio.h>
#include <string>
#include <iostream>

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    
    while(scanf("%d",&n)!=EOF){
        int temp = 0;
        if(n==1){
            printf("%d",0);
        }else{
            for(int i=2; i<=n; i++ ){
                temp+=sosuu(i);
                if(i!=2){
                    i++;
                }
            }
            printf("%d\n",temp);
        }
    }
    
    
}

int sosuu(int n){
    for(int i=2; i<n/2; i++){
        if(n%i == 0){
            return 0;
        }
        if(i!=2){
            i++;
        }
    }
    return 1;
}

C++: #include<stdio.h>
#define MAX_N 100000

int main(void){
	int prime[MAX_N],is_prime[MAX_N+1];
	int n,p,i,j;
 

	while(scanf("%d",&n)!=EOF){
	
		p=0;
	
		for(i=0;i<n;i++){
			is_prime[i]=1;	//f»èzñÌú»
		}
	
		is_prime[0]=0;
		is_prime[1]=0;	//0Æ1ÍfÅÍÈ¢ÌÅ\ßæè­
	
		for(i=2;i<=n;i++){
			if(is_prime[i]==1){
				prime[p++]=i;
				for(j=2*i;j<=n;j=j+i){
					is_prime[j]=0;
				}
			}
		}
		printf("%d\n",p);
	}
	return 0;
}

C++: #include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;

int main(){
    int n, i;
    while(scanf("%d", &n) != EOF){
        int cnt = 0;
        for(; n>1; n--){
            for(i=2; i<=sqrt(n)+1; i++){
                if(n%i == 0) break;
            }
            if(i>sqrt(n)) cnt++;
        }
    cout << cnt <<endl;
    }
}

C++: //Prime Number
#include <iostream>
#include <cstdio>
using namespace std;

int main() {
	const int MAX = 1000000;
	bool isPrime[MAX];
	for(int i = 0; i < MAX; i++) {
		isPrime[i] = true;
	}
	
	for(int i = 2; i*i < MAX; i++) {
		if(isPrime[i]) {
			for(int j = i*i; j < MAX; j += i) {
				isPrime[j] = false;
			}
		}
	}
	
	int n;
	while(cin >> n) {
		int count = 0;
		for(int i = 2; i <= n; i++) {
			if(isPrime[i]) count++;
		}
		cout << count << endl;
	}
	
	return 0;
}

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

using namespace std;

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

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin>>n){
        int count=1;

        if(n%2==0){
            n--;
        }
        while (1 < n){
            int prime_flag=1;
            for (int j = n - 1; prime_flag && 1 < j; j--) {
                if(n % j==0){
                    prime_flag=0;
                }
            }
            count+=prime_flag;
            n-=2;
        }
        cout<<count<<endl;
    }
    return 0;
}

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

#define MAX 1000000

int main(){
	bool p[MAX+1];
	int num,answer;
	p[0] = false;
	p[1] = false;
	for(int i=2 ; i<=MAX ; i++){
		p[i] = true;
	}
	for(int i=2 ; i<=sqrt(MAX)+1 ; i++){
		if(p[i]==1){
			for(int j=i*2; j<=MAX; j=j+i){
				p[j] = false;
			}
		}
	}
		
	while( scanf("%d" , &num) != EOF ){	
		answer = 0;	

		for(int i=0; i<=num; i++){
			if(p[i]){
				answer++;
			}
		}
		printf("%d\n", answer);
	}
}