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 <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int gcd(int a,int b){if(a%b==0){return b;}else return gcd(b,a%b);}
int lcm(int a,int b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

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

signed main(){
  int n;
  while(cin>>n&&n){
    if(n==1){cout<<0<<en; RE;}
    int ans=0;
    for(int i=2; i<=n; i++){
      if(isprime(i)) ans++;
    }
    cout<<ans<<en;
  }
}

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

bool is_SPRP(uint32_t n, uint32_t a) {
  uint32_t d = n - 1, s = 0;
  while ((d & 1) == 0) {
    ++s;
    d >>= 1;
  }
  uint64_t cur = 1, pw = d;
  while (pw) {
    if (pw & 1) {
      cur = (cur * a) % n;
    }
    a = ((uint64_t)a * a) % n;
    pw >>= 1;
  }
  if (cur == 1) {
    return true;
  }
  for (uint32_t r = 0; r < s; r++) {
    if (cur == n - 1) {
      return true;
    }
    cur = (cur * cur) % n;
  }
  return false;
}

bool is_prime(uint32_t x) {
  if (x <= 1) return false;
  if (x < 1ULL << 32) {
    uint32_t bases[] = {2, 7, 61};
    for (uint32_t i = 0; i < sizeof(bases) / sizeof(bases[0]); ++i) {
      if (x != bases[i] && !is_SPRP(x, bases[i])) {
        return false;
      }
    }
    return true;
  }
}

int main() {
  int n;
  while (cin >> n) {
    int ans = 0;
    for (int i = 1; i <= n; ++i) {
      if (is_prime(i)) ans++;
    }
    cout << ans << endl;
  }
}

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

int main() {
int b[1000000];
for (int k=0;k<1000001;k++){
	b[k]=0;
}
for (int p=2;p<1000001;p++){
int i,a=0 ;
	i=2;
	while(i<p){
		if(p%i==0){
			break;
	}i=i+1;
	}
	if (i==p){
		a=1;
	}
	b[p]=a;
}
int c[1000000];
for (int l=0;l<1000001;l++){
	c[l+1]=c[l]+b[l+1];
}
int r;
while(cin>>r){
	cout<<c[r]<<endl;
}
	return 0;
}

C++: #include <iostream>
#include <cmath>
#include <vector>
using namespace std;
// have you mooed today?
bool isprime(int& num)
{
    static int c;
    static int max;
    if(num == 1) return false;
    if(num == 2) return true;
    if(num % 2 == 0) return false;
    max = ceil(sqrt(num));

    for(c=3; c < max+1; c+=2)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans =0;
    int c;
    int buff;
    vector<int> prime;
    for(c=1;c<=999999;c++)
    {
        if(isprime(c)) ans++;
        prime.push_back(ans);
    }
    cout << prime[0] << endl;
    while(cin >> buff)
    {
        cout << prime[buff -1] << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
bool flg[1000000];
int main(void){
	int n;
	int i,j;
	int cnt=0;
	while(1){
		cin>>n;
		if(cin.eof())	break;
		fill(flg,flg+n+1,0);
		for(i=2;i*i<=n;i++){
			//cout<<"I="<<i<<endl;
			for(j=2;i*j<=n;j++){
				//cout<<"J="<<j<<endl;
				flg[i*j]=1;
			}
		}
		cnt=0;
		for(i=2;i<=n;i++)	if(flg[i]==0)	cnt++;
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include<iostream>
int fact(int x){
	int sx=0,sy=0;
	for(int i=2;i<x+1;i++){
		if(x%i==0)sx++,sy+=i;
	}
	if(sx==1)return x;
	else return sy+1;
}
int main(){
	int a=0;
	while(std::cin>>a){
		int n=0;
		for(int i=2;i<a+1;i++){
			if(i==fact(i))n++;
		}
		std::cout<<n<<std::endl;
	}

	return 0;
}

C++: #include<iostream>
using namespace std;
int main()
{
	int N;
	int count;

	while(cin>>N)
	{
		count=0;
		for(int i=2;i<=N;i++)
		{
			int f=0;
			for(int j=1;j<i;j++)
				if((i%j)==0)
					f++;
			if(f<2)count++;
		}

		cout<<count<<endl;
	}

	return 0;
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30][2]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num][0]=n;
        num++;
    }
    
    int b[max];
    for(int i=0; i<=max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        for(int j=i+1; j<=max; j++){
            if(j%i==0){
                b[j]=0;
            }
        }
    }
    
    
//    for(int j=0; j<num; j++){
//        cout<<a[j][0]<<"\n";
//    }
//    
//    for(int j=0; j<=max; j++){
//        cout<<b[j]<<"\n";
//    }
    
    
    
    for(int i=0; i<num; i++){
        for(int j=0; j<=a[i][0]; j++){
            if(b[j]!=0){
                a[i][1]++;
            }
        }
    }

    
    for(int j=0; j<num; j++){
        cout<<a[j][1]<<"\n";
    }
    
}

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

using namespace std;

long long int n,i;
int a[1000001] = {0};
int ans;

int main()
{
    for(int i = 2; i < 1000000; i++)
    {
        if(a[i] == 0)
        {
            for(int j = 2; i * j <= 1000000; j++)
            {
                a[i * j] = 1;
            }
        }
    }
    while(cin >> n)
    {
        for(int i = 2; i <= n; i++)
        {
            if(a[i] == 0)ans++;
        }

        /*for(int i = 2; i <= n; i++)
        {
            if(i == 2 || i == 3 ||  i == 5 || i == 7)ans++;

        }*/
        cout << ans << endl;
        ans = 0;
    }
    return 0;
}

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 <stdio.h>
int isprime(int n){
  for(int i = 2; i * i <= n; i++){
    if(n % i == 0)return 0 ;
  }
  return 1;
}
int main(){
  int n;
  while(1){
    scanf("%d",&n);
    if(n == 0)break;
    for(int i = n; i > 3; i--){
      if(isprime(i) == 1 && isprime(i-2) == 1){
        printf("%d %d\n",i-2,i);
        break;
      }
    }
  }
  return 0;
}

C++: #include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <iomanip>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
const int inf = 1e9;
const ll linf = 1LL << 50;

int n;
bool is_prime[1000000];
int prime[1000000];

int main(int argc, char const* argv[])
{
	fill(is_prime, is_prime+1000000, true);
	is_prime[0] = false;
	is_prime[1] = false;
	int res = 0;
	for(int i = 2; i < 1000000; i++){
			if(is_prime[i]){
					res++;
					for(int j = 2; j * i < 1000000; j++){
							is_prime[j * i] = false;
					}
			}
			prime[i] = res;
	}
	while(cin >> n){
			cout << prime[n] << endl;
	}
	return 0;
}