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 := i - 1; j >= 1; j-- {
				if i%j == 0 && j != 1 {
					flag = true
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

C++: #include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

typedef long long ll;

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

// ref. YouTube ABC 152 E
class EratosthenesSieve {
    public:
        const int N;

        EratosthenesSieve(const int N): N(N) {
            numbers.resize(N + 1, 0);
            init();
        }

        // assume that n > 0 && n <= N
        map<int, int> factors(int n) {
            // assert(n > 0 && n <= N); 
            map<int, int> res;
            while (n > 1) {
                res[numbers[n]]++;
                n /= numbers[n];
            }
            return res;
        }

        void primes(vector<int> &p) {
            for (int i = 2; i <= N; i++) {
                if (is_prime(i)) {
                    p.push_back(i);
                }
            }
        }

        // assume that n > 0 && n <= N
        bool is_prime(const int n) {
            // assert(n > 0 && n <= N);
            return numbers[n] == n;
        }

    private:
        vector<int> numbers; // numbers[i] means minimum prime factor for i (e.g. numbers[12] = 2)

        void init() {
            // O(N * log(logN)) ???
            int i = 2;
            for (; i * i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                    for (int j = i * i; j <= N; j += i) {
                        if (numbers[j] == 0) {
                            numbers[j] = i;
                        }
                    }
                }
            }
            for (; i <= N; i++) {
                if (numbers[i] == 0) {
                    numbers[i] = i;
                }
            }
        }
};

const int MAX_N = 999999;

// ref. http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009
int main(void) {
    EratosthenesSieve *sieve = new EratosthenesSieve(MAX_N);
    vector<int> ps;
    sieve->primes(ps);

    char buf[1024];
    while (fgets(buf, 1024, stdin) != NULL) {
        int x = atoi(buf);
        auto y = upper_bound(ps.begin(), ps.end(), x);
        cout << y - ps.begin() << endl;
    }

    delete sieve;
    return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

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

signed main(){
  int n;
  while(cin>>n){
    int ans=0;
    loop(i,1,n+1)if(Is_Prime(i))ans++;
    cout<< ans<<endl;
  }
  return 0;
}

C++: #include<iostream>

int main(){
  int prime[200000];
  int k,n;
  prime[0]=2;
  while(std::cin >> n){
    if(n==1){
      std::cout << 0 << std::endl;
      continue;
    }
    k=0;
    for(int i=3;i<=n;i++){
      for(int j=0;j<=k;j++){
        if(i%prime[j]==0){
          break;
        }
        if(j==k){
          ++k;
          prime[k]=i;
        }
      }
    }
    std::cout << k+1 << std::endl;
  }
}

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

int main()
{
	int n = 0, x = 0;
	int countdata[1000];
	while (cin >> n) {
		int count = 0;
		for (int a = 2; a <= n; a++) {
			if (a % 2 != 0 && a % 3 != 0 && a % 5 != 0 && a % 7 != 0) 
				count++;
			if (a == 2 || a == 3 || a == 5 || a == 7)
				count++;
		}
		countdata[x] = count;
		x++;
	}
	for (int a = 0; a < x; a++) {
		cout << countdata[a] << endl;
	}
}

C++: #include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;
static const double EPS = 1e-10;

int main(){
	vector<int> p;
	bool b;
	int n;

	while(cin >> n){
		p.clear();
		if(n > 1){
			p.push_back(2);
			for(int i = 3; i <= n; i++){
				b = true;
				for(int j = 0; j < p.size(); j++){
					if(p[j]*p[j] > i){
						break;
					}
					if(i % p[j] == 0){
						b = false;
						break;
					}
				}
				if(b){
					p.push_back(i);
				}
			}
		}
		cout << p.size() << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
using namespace std;
#define MAX 1000000
int main( void )
{
	vector <bool> primes(MAX+1, false);

	for ( int i = 3; i <= MAX; i += 2 )
	{
		primes[i] = true;
	}

	for ( int i = 3; i <= MAX; i += 2 )
	{
		if ( primes[i] )
		{
			for ( int j = i + i; j <= MAX; j += i )
			{
				primes[j] = false;
			}
		}
	}

	int n;
	cin >> n;

	int c = 0;
	if ( n == 2 )
		c = 1;
	else if( n < 2 )
		c = 0;
	else
	{
		c = 1;
		for ( int i = 3; i <= n; i += 2 )
		{
			if ( primes[i] )
				c++;
		}
	}

	cout << c << endl;

	return 0;
}

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

int primes[1000000]={0};


int main(){
    primes[0] = -1;
    primes[1] = -1;
    for(int i=2; i<1000; i++){
        if(primes[i]==-1) continue;
        for(int j=i+1; j<1000000; j++){
            if(j%i==0) primes[j] = -1;
        }
    }
    puts("hoge");
    int n;
    while(-1!=scanf("%d", &n)){
        int ans = 0;
        for(int i=2; i<=n; i++){
            if(primes[i] == 0) ans++;
        }
        cout << ans << endl;
    }
}

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

using namespace std;

int ans = 0;

void Prime_number(int n){
	int i;
	int prime_num;

	for(i = 2; ; i++){
		if(n % i == 0 && n != i){
			break;
		}else if(n == i){
			ans++;
			break;
		}
	}

	if(n != 2){
		Prime_number(n-1);
	}
}

int main(){
	int n;

	while((scanf("%d",&n)) != EOF){
		Prime_number(n);
		cout << ans << endl;
		ans = 0;
	}

}

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

using namespace std;

int main()
{
    int n;
    int prime[800];
    int ptr = 0;

    prime[ptr++] = 2;
    prime[ptr++] = 3;

    while (cin >> n) {
        if (n == 2) {
            cout << "1\n";
            continue;
        }
        else if (n == 3) {
            cout << "2\n";
            continue;
        }

        int count = 2;        
        for (int i = 5; i <= n; i += 2) {
            bool flag = false;
            for (int j = 1; prime[j] * prime[j] <= i; j++) {
                if (!(i % prime[j])) {
                    flag = true;
                    break;
                }
            }
            if (!flag) {
                prime[ptr++] = i;
                count++;
            }
        }
        cout << count << "\n";
    }
    
    return 0;
}

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

int main (void){
	int number, i, j, count=0;
	
	while(scanf("%d", &number)!=EOF){
	count=0;
	int n[number];
	for(i=0; i<number; i++){
		n[i]=i;
	}
	
	for(i=0; i<number; i++){
		j=i;
		while(1){
			j+=i;
			if(j>number){break;}
			n[j]=-1;
			if(i==0 || i==1){
				n[i]=-1;
				break;
			}
		}
	}
	
	for(i=0; i<number; i++){
		if(n[i]!=-1){
			//printf("%d\n", n[i]);
			count++;
		}
	}
	printf("%d\n", count+1);
	}
	
	return 0;
}