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<iostream>
#include<math.h>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
using namespace std;
#define INF 1<<20

struct edge{
	int to;
	int cost;
	edge() {};
	edge(int a, int b) {
		to = a;
		cost = b;
	}
};

struct Node {
	int pos;
	int cost;
	Node() {};
	Node(int a, int b) {
		pos = a;
		cost = b;
	}
	bool operator <(const Node& rhs) const {
		return cost > rhs.cost;
	}
};

void dijkistra(int st, int TO,int V,vector<vector<edge> > graph) {
	priority_queue<Node> q;
	vector<int> d(V);
	for (int i = 0;i < V;i++) {
		d[i] = INF;
	}
	d[st] = 0;
	q.push(Node(st, 0));
	while (!q.empty()) {
		Node s = q.top(); q.pop();
		int pos = s.pos;
		for (int i = 0;i < graph[pos].size();i++) {
			int to = graph[pos][i].to;
			int cost = graph[pos][i].cost;
			if (d[pos] + cost < d[to]) {
				d[to] = d[pos] + cost;
				q.push(Node(to, d[to]));
			}

		}
	}
	cout << d[TO] << endl;
}
int partition(int A[],int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p;j < r;j++) {
		if (x >= A[j]) {
			i = i + 1;
			swap(A[i], A[j]);
		}
	}
		swap(A[i + 1], A[r]);
		return i + 1;
}
void quicksort(int A[], int p, int r) {
	if (p < r) {
		int q = partition(A, p, r);
		quicksort(A, p, q-1);
		quicksort(A, q + 1, r);
	}
}

int getNumberOfCoin(int C[],int n,int m) {
	int T[50000];
	for (int j = 0;j <= n;j++) {
		T[j] = INF;
	}
	T[0] = 0;
	for (int i = 0;i < m;i++) {
		for (int j = 0;j <= n;j++) {
			if (j - C[i] >=0  ) {
				T[j] = min(T[j], T[j - C[i]] + 1);
			}
		}
	}
	return T[n];
}
int knapsack(int w, int n,int* v,int* ww) {
	int W[101][10001];
		for (int j = 0;j <= w;j++) {
			W[0][j] = 0;
		}
	for (int i = 0;i < n;i++) {
		for (int k = 0;k < n;k++){
			for (int j = 0;j <= w;j++) {
				if (j - ww[k] < 0) {
					W[i + 1][j] = W[i][j];
				}
				if (j - ww[i] >= 0) {
					W[i + 1][j] = max(W[i][j], W[i][j - ww[k]] + v[k]);

				}
			}
		}
	}
	return W[n][w];
}
int fib(int n) {
	vector<int> v(n+1);
	v[0] = 1;
	v[1] = 1;
	for (int i = 2;i < n+1;i++) {
		v[i] = v[i - 2] + v[i - 1];
	}
	return v[n];
}
int isPrime(int x) {
	if (x <= 1) return false;
	if (x>2 && x % 2 == 0) return false;
	for (int i = 2;i <= sqrt(x);i++) {
		if (x%i == 0) {
			return false;
		}
	}
	if (x == 2) return true;
	return true;
}
int Prime(int x) {
	vector<int> prime(x+1,1);
	int num = 2;
	while (num <= sqrt(x)) {
		for (int i = 2;i <= x / num;i++) {
			prime[num*i] = 0;
		}
		num++;
		while (prime[num] == 0)
			num++;
	}
	int count = 0;
	for (int i = 2;i < x + 1;i++) {
		if (prime[i] == 1) count++;
	}
	return count;
}
int main(){
	int n;
	vector<int> a;
	while (cin >> n) {
		a.push_back(n);
	}
	for (int j = 0;j < a.size();j++){
		cout<<Prime(a[j])<<endl;
	}
	

}

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

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 114514810
#define ELEM(array) (sizeof (array)/sizeof *(array))
#define MAX_N 100
#define SAFE_FREE(ptr) if( ptr != NULL ){ free(ptr); ptr = NULL; }
typedef unsigned int UINT;
#define ll long long
typedef pair<int, int> P;

bool prime[100005];
void solve()
{
	memset(prime, true, sizeof(prime));
	prime[0] = prime[1] = false;
	FOR(i, 2, (int)sqrt(100005))
	{
		if (prime[i] == true)
		{
			FOR(j, 2, (int)sqrt(100005)){
				if (prime[i*j] == true)prime[i*j] = false;
			}
		}
	}
}

int main()
{
	int n;
	while (cin >> n)
	{

		int ans = 0;

		solve();
		REP(i, n + 1){
			if (prime[i] == true){
				ans++;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

bool primes[1000000];
void Prime(){
  primes[0] = false; primes[1] = false;
  for (int i = 2; i < 1000000; i++) primes[i] = true;
  for (int i = 2; i < 1000; i++) {
    if (primes[i]) {
      for (int j = i * 2; j < 1000000; j += i) primes[j] = false;
    }
  }
}

int main() {
  Prime();
  int n;
  while(cin >> n) {
    int cnt = 0;
    for (int i = 2; i <= n; i++) if (primes[i]) cnt++;
    cout << cnt << endl;
  }
  return 0;
}

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

int main() {
  int n;
  while (cin >> n) {
    int count = 0;
    if (n >= 2){
      count++;
    }
    for (int i = 3; i <= n; i += 2) {
      for (int j = 2; j < i; j++) {
	if (i % j == 0) {
	  break;
	}
	if (j == i-1) {
	  count++;
	}
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<iostream>
using namespace std;
int prime(int x)
{
    int i,j=0,k;
    for(i=2;i<=(x/2);i++)
    {
        if(x%i==0)
        {
            j=1;
            break;
        }
    }
    if(j==1) return 1;
    else return 0;
}
int main()
{
    int i,s,j;
    while(cin>>i)
    {


    s=0;
    for(j=2;j<=i;j++)
    {
        if((prime(j))==0)
        {
            s+=1;
        }

    }
    cout<<s<<endl;
    }



    return 0;
}

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

using namespace std;

long long int num[100000100];

void erat(int n) {
    for (int i = 0; i <= n; i++) num[i] = true;

    num[0] = num[1] = false;

    for (int i = 2; i * i <= n; i++) {
        if (!num[i]) continue;
        else {
            for (int j = 2*i; j <= n; j += i) {
                num[j] = false;
            }
        }
    }
}

int main()
{
    int n, cnt = 0;

    while (cin >> n) {
        erat(n);
        for (int i = 0; i <= n; i++) {
            if (num[i]) cnt++;
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

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

int main(void)
{
	int num, cnt;
	unsigned int i, j, k, data_num;
	int data[50];
	unsigned int sq_num;
	unsigned int *prime;

	for (data_num = 0; data_num < 50; data_num++) {
		data[data_num] = -1;
		scanf("%d", &data[data_num]);
		if (data[data_num] < 0) {
			break;
		}
	}

	for (k = 0; k < data_num; k++) {
		sq_num = (int)sqrt((double)data[k]);
		prime = (unsigned int*)malloc(sizeof(unsigned int) * data[k]);

		for (i = 0; i < data[k]; i++) {
			prime[i] = 1;
		}

		prime[0] = 0;
		for (i = 1; i < sq_num; i++) {
			if (prime[i] == 1) {
				for (j = (i + 1); (i + 1) * j <= data[k]; j++) {
					prime[(i + 1) * j - 1] = 0;
				}
			}
		}

		cnt = 0;
		for (i = 0; i < data[k]; i++) {
			if (prime[i] == 1) {
				cnt++;
				//printf("%d", i + 1);
			}
		}

		printf("%d\n", cnt);

		free(prime);
	}

	return 0;

}

C++: #include <iostream>
#include <cmath>
using namespace std;
#define MAX 1000000


int main(){
	bool work[MAX];
	int num, ans = 0;

	// 入力
	cin >> num;

	// 初期化
	for(int i = 0; i < MAX; i++){
		if(i < 2){
			work[i] = false;
		}else{
			work[i] = true;
		}
	}

	// エラトネスのふるい
	for(int i = 2; i < sqrt((double)MAX) + 1; i++){
		if(work[i] == true){
			for(int j = i * 2; j < MAX; j += i){
				work[j] = false;
			}
		}
	}

	// 計算
	for(int i = 0; i <= num; i++){
		if(work[i] == true){
			ans++;
		}
	}

	// 出力
	cout << ans << endl;

	return 0;
}

C++: #include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int pt[1000000];

int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 2; i <= n; i++) if (pt[i] == 0) {
        ans++;
        for (int j = i+i; j <= n; j+=i) pt[j] = i;
    }
    printf("%d\n", ans);
    return 0;
}

C++: #include<cstdio>
#include<cstring>
int main(){
 int n,cnt=0;
 scanf("%d",&n);
 int a[n+1];
 memset(a,-1,sizeof(int)*(n+1));
 for(int i=2;i<=n;i++){
 if(a[i]==-1){ cnt++;
 for(int j=i;j<=n;j=j+i) a[j]=0;}
}
printf("%d\n",cnt);
return 0;
}