Go: package main

import (
        "fmt"
)

const MAX int = 1000000
var primes [MAX]int

func main() {
        Init()
        var n, cnt int
        for {
                _, err := fmt.Scanf("%d", &n)
                if err != nil {
                        break
                }
                cnt = 0
                for i := 2; i <= n; i++ {
                        cnt += primes[i]
                }
                fmt.Printf("%d\n", cnt)
        }
}

func Init() {
        for i := 0; i < MAX; i++ {
                primes[i] = 1
        }
        primes[0] = 0
        primes[1] = 0
        Soe()
}

func Soe() {
        for i := 2; i < MAX; i++ {
                if primes[i] > 0 {
                        for j := i*2; j < MAX; j+=i {
                                primes[j] = 0
                        }
                }
        }
}

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

using namespace std;

int main()
{
	int i,j;
	char array[1000010];
	
	for(i=0;i<1000001;i++)
		array[i]='1';
	
	array[0]=array[1]='0';
	
	for(i=0;i<1000001;i++)
	{
		if(array[i]=='1')
		{
			for(j=2;i*j<1000001;j++)
				array[i*j]='0';
		}
	}
	
	vector<int> ans;
	
	for(i=0;i<1000001;i++)
	{
		ans.push_back(0);
	}
	for(i=1;i<1000001;i++)
	{
		ans[i]+=ans[i-1];
		ans[i]+=(int)array[i]-48;
	}
	
	int inp;
	for(;cin >> inp;)
	{
		cout << ans[inp] << endl;
	}
}

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

bool isPrimeNumber(const unsigned long n);

int main(){
    unsigned long n;
    vector<unsigned long> pri;
    while(cin>>n){
        unsigned ans = 0;
        for(unsigned long i=1;i<=n;i--){
            bool serch = true;
            vector<unsigned long>::iterator it = pri.begin();
            while(it!=pri.end()){
                if(fmodl(n,*it)==0){
                    ans++;
                    serch = false;
                    break;
                }
            }
            if(isPrimeNumber(i)&&serch){
                ans++;
                pri.push_back(i);
            }
        }
        cout << ans << endl;
    }
}

bool isPrimeNumber(const unsigned long n){
    static const unsigned long carn[]{
        561,	1105,	1729,	2465,	2821,	6601,	8911,
        10585,	15841,	29341,	41041,	46657,	52633,	62745,	63973,	75361,
        101101,	115921,	126217,	162401,	172081,	188461,	252601,	278545,	294409,
        314821,	334153,	340561,	399001,	410041,	449065,	488881,	512461,	530881,
        552721,	656601,	658801,	670033,	748657,	825265,	838201,	852841,	997633,
        1024651,1033669,1050985,1082809,1152271,1193221,1461241,1569457,1615681,
        1773289,1857241,1909001,2100901,2113921,2433601,2455921,2508013,2531845,
        2628073,2704801,3057601,3146221,3224065,3581761,3664585,3828001,4335241,
        4463641,4767841,4903921,4909177,5031181,5049001,5148001,5310721,5444489,
        5481451,5632705,5968873,6049681,6054985,6189121,6313681,6733693,6840001,
        6868261,7207201,7519441,7995169,8134561,8341201,8355841,8719309,8719921,
        8830801,8927101,9439201,9494101,9582145,9585541,9613297,9890881
    };

    if(n==2)
        return true;
    else if(n<2||n%2==0)
        return false;
    else{
        for(unsigned long i=0;i<sizeof(carn)/sizeof(carn[0]);i++){
            if(n<carn[i])
                break;
            if(n==carn[i])
                return false;
        }
        for(unsigned long i=n-1;i>0;i--){
            if(fmodl(powl(i,n),n)!=i)
                return false;
        }
        return true;
    }
}

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;
}