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>
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
int pcount[MAX_V+1];
int main() {
    int i, k,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    for(i=0;i<30;i++){
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

C++: #include <iostream>

using namespace std;

int main(){
  int n,visited,cnt=0;
  
  while(cnt<30){
    int count =0;
    cnt++;
    cin >> n;
    if(n==0)count =0;
    for(int j=2;j<=n;j++){
      visited=0;
      for(int i = 2;i<=n;i++){
	
	if(j%i==0&&j!=i)visited=1;
	else if(j%i==0&&j==i&&visited==0)count++;
	/*	cout<<"j/"<<j<<" i:"<<i <<" count:"<<count<<" visited"<<visited<<endl;    */ 
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include <stdio.h>

int ans ;
int N ;
bool prime[100020] ;

void SE ( ) ;

int main ( ) 
{
	SE ( ) ;
	while ( scanf ( "%d" , &N ) == 1 ) {
		ans = 0 ;
		if ( N > 2 ) {
			ans++ ;
		}
		for ( int i = 3 ; i < N ; i += 2 ) {
			if ( prime[i] == false ) {
				ans++ ;
			}
		}
		printf ( "%d\n" , ans ) ;
	}
	return 0 ;
}

void SE ( )
{
	prime[0] = prime[1] = true ;
	for ( int i = 3 ; i < 1004 ; i += 2 ) {
		if ( prime[i] == false ) {
			for ( int j = i * i ; j < 100020 ; j += i * 2 ) {
				prime[j] = true ;
			}
		}
	}
}

C++: #include<iostream>
using namespace std;
int main() {
  int n;
  while(cin>>n) {
    int Count=0;
    for(int i=1;i<=n;i++) {
      int count=0;     
      if(i!=1) {
	for(int j=1;j<=i;j++) {
	  if(i%j==0)
	    count++;
	}
	if(count==2) 
	  Count++;
      }
    }
    cout<<Count<<endl; 
  }
 return 0;
}

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

#define N 1000000L
bool num[N];

void furui() {
	long int i;
	int divide;
	int rt = 1000;
	for (i = 0L; i < N; i++) {
		num[i] = true;
	}
	num[0L] = false;
	num[1L] = false;
	for (divide = 2; divide <= rt; divide++) {
		if (num[divide] == false) continue;
		for (i = (long int)divide; i < N; i += divide) {
			num[i] = false;
		}
		num[divide] = true;
	}
}

int main(void) {
	int c, i, j;
	long int k;
	char buf[7];
	long int n;
	long int count;

	furui();

	for (j = 0; j < 30; j++) {
		for (i = 0; ; i++) {
			c = getchar();
			if (c == EOF || c == '\n') {
				buf[i] = '\0';
				break;
			}
			buf[i] = c;
		}
		n = atol(buf);
		count = 0L;
		for (k = 1L; k <= n; k++) {
			if (num[k] == true) count++;
		}
		std::cout << count << std::endl;
		if (c == EOF) break;
	}
	return 0;
}

C++: #include<stdio.h>

int main(void)
{
	int data,i,j,k=0,l=0,kai[100]={0},s[100000]={0};

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai[k]=0;
		else
		{
			for(i=2;i<=data;i++)s[i]=i;

		    i=2;
			while(i*2<data)
			{
			  if(s[i] != 0)
			  {  
				j=2;
				while(j*i<=data)
				{
					s[j*i]=0;
					j+=1;
				}
			  }
			  i+=1;
			}

			
			for(i=2;i<=data;i++)
			{	
				if(s[i]!=0)
				{
					kai[k]+=1;
				}
			}
		}
		k+=1;
	}

  for(j=0;j<k;j++)
    printf("%d\n",kai[j]);
  return 0;
}

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

int main()
{
  int n;
  int cou1, cou2;
  while (scanf("%d", &n) != EOF){
    cou2 = 0;
    for (int i = 2; i <= n; i++){
      cou1 = 0;

      for (int j = 1; j <= n; j++){

        if (i % j == 0){
          cou1++;
        }
      }
      if (cou1 == 2){
        cou2++;
      }
    }
    cout << cou2 << "\n";
  }

  return 0;
}

C++: //
//  main.cpp
//  CppTest
//
//  Created by Ryu on 2017/02/08.
//  Copyright ?? 2017??´ Ryu. All rights reserved.
//

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    // insert code here...
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    
    long in[30];
    long out[30];
    int n = 0;
    long max = 0;
    while(cin >> in[n]){
        if(max < in[n]){
            max = in[n];
        }
        n++;
    }
    //printf("%d", n);
    
    long p[100000];
    p[0] = 2;
    int m = 1;
    for (int i = 3; i <= max; i += 2) {
        bool prime = true;
        for(int j = 0; j < m; j++){
            if (i % p[j] == 0) {
                prime = false;
                break;
            }
            if (i < pow(p[j], 2)) {
                break;
            }
        }
        if (prime) {
            p[m] = i;
            //printf("%ld\n", p[m]);
            m++;
        }
    }
    
    
    for (int i = 0; i < n; i++) {
        int s = 0;
        while (in[i] >= p[s] && p[s] != 0) {
            //printf("in: %ld, p: %ld\n", in[i], p[s]);
            s++;
        }
        out[i] = s;
        printf("%ld\n", out[i]);
    }
    
    return 0;
}

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

using namespace std;

class Prime {
// n以下の素数を列挙する
public:
  const int n;
  vector<bool> is_prime;
  vector<int> primes;
  Prime(int size) : n(size), is_prime(n+1, true) {
    is_prime[0] = false;
    is_prime[1] = false;
    for (int i = 2; i <= n; ++i) {
      if (!is_prime[i]) continue;
      primes.push_back(i);
      int tmp = 2*i;
      while (tmp <= n) {
        is_prime[tmp] = false;
        tmp += i;
      }
    }
  }

  bool check(int x) { return is_prime[x]; }
};

int main() {
  Prime prime(1000001);
  int n;
  while (cin >> n) {
      int ans = 0;
      for (int p : prime.primes) {
          if (p > n) break;
          ++ans;
      }
      cout << ans << endl;
  }
}

C++: #include<stdio.h>
int main(void){
   int s[10000], l, m, n, i, sum;
   sum = 0;
   for ( i = 1; i <= 1000000; i++ ) {
      s[i] = 0;
   }
   for ( k = 2; k <= 1000000; k++ ){
      if (s[k] == 0) {
         for ( l = 2; l <= 100000 / k; l++ ) {
            s[k * l] = 1;
         }
      }
   }
   while(scanf("%d", &n) != EOF){
      for(i = 1; i <= n; i++){
         if(s[i] == 0){
            sum++;
         }
      }
   }
   printf("%d", sum);
   return 0;
}

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

using namespace std;

int main(void) {
	int n;
	
	vector<int> prmcnt_v;

	while(cin >> n) {
		int pcnt = 0;
		for (int i = 2; i <= n; i++) {
			for (int j = 2; j <= i; j++) {
				if (i % j == 0){
					if (i == j) {
						pcnt++;
					}
					else {
						break;
					}
				}
			}
		}
		prmcnt_v.push_back(pcnt);
	}


	for (int k = 0; k < prmcnt_v.size(); k++) {
		cout << prmcnt_v[k] << endl;
	}

	return 0;
}

C++: #include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 1e6+7;
int prime[maxn];
bool is_prime[maxn];
int n,p=-1;

void Eular()
{
    for(int i=1;i<=maxn-7;i++)
        is_prime[i]=true;
    for(int i=2;i<=maxn-7;i++)
    {
        if(is_prime[i])
            prime[++p]=i;
        for(int j=0;j<=p && i*prime[j] <= maxn-7;j++)
            is_prime[i*prime[j]]=false;
    }
}

int main()
{
    Eular();
    while(~scanf("%d",&n))
    {
        int i=0,ans=0;
        while(prime[i]<=n) i++,ans++;
        printf("%d\n",ans);
    }
    return 0;
}