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

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

int prime[1000000];


bool isPrime(int n) {
  int x = sqrt(static_cast<double>n);
  for (int i = 3; i <= x; i += 2) {
    if (n % i == 0) {
      return false;
    }
  }
  return true;
}


void get_prime(int max_num) {
  int primecount = 1;
  prime[2] = primecount;
  for (int i = 3; i <= max_num; i += 2) {
    if (isPrime(i))
      prime[i] = ++primecount;
    else
      prime[i] = primecount;
  }
}


int main () {
  int ns[31];
  int i = 0, max_num;
  while (std::cin >> ns[i]) {
    max_num = std::max(max_num, ns[i]);
    if (ns[i] % 2 == 0)
      ns[i] --;
    i ++;
  }
  get_prime(max_num);
  for (int j = 0; j < i; j ++) {
    std::cout << prime[ns[j]] << std::endl;
  }
  return 0;
}

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

int main(){
int n;
int b;
int c;
int d;
while(cin >> n){
int a[n+1];
b=1;
while(b<n+1){
a[b]=0;
b=b+1;}
a[1]=1;
d=0;
b=2;
while(b<n+1){
if(a[b]==0){d=d+1; c=2; while(1){if(c*b>n){break;} a[c*b]=1; c=c+1;}}
b=b+1;}
cout << d;}


}

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;

}