Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [40]int
	var inputCount, primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		resultArr[inputCount] = primeCount
		if inputCount == 30 {
			break
		}
		primeCount = 0
		inputCount++
	}
	for _, v := range resultArr {
		fmt.Printf("%d\n", v)
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2:
		return true
	case num < 2 || num%2 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

C++: /* All men have limits. They learn what they are and learn
   not to exceed them, I ignore mine. -Batman           */
#include <bits/stdc++.h>
//#include <iostream>
//#include <Windows.h>
using namespace std;
bool prime(int n){
	if(n==0||n==1)return 0;
	else if(n==2)return 1;
	else
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0)return 0;
	}
	return 1;
	
}

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

}

return 0;
}

C++: #include<iostream>
#include<algorithm>
#include<cstdio>
using namespace std;
 
int main(){
int unti[1000001] = {0};
fill(unti,unti + 1000001,0);
for(int n = 2;n < 1000001;n++)
{
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 1000001;a++)
{
    if((a * n  ) < 1000001 ) unti[a * n]++;
}
}
}
int b;
while(cin >> b )
{
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt ;
    }
 
 
}

C++: #include <stdio.h>
  
int main(){
   long int e[30];
  
    int k = 0;
    while( scanf( "%d",&e[k] ) != EOF )k++;
  
    for( int i = 0;i < k;i++ ){
        int n = 10;
        int k = 1;
        while( true ){
            if( e[k] >= n ){
                k++;
                n *= 10;
            } else {
                break;
            }
        }
        printf( "%d\n",k );
    }
    return 0;
}

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

int main(){
  bool prime[1000000];
  int np[1000000], n;

  for(int i=2; i<1000000; i++){
    if(!prime[i]){
      for(int j=2; j*i<1000000; j++){
	prime[i*j] = true;
      }
    }
    np[i] = np[i-1] + !prime[i];
  }

  while(cin >> n)
    cout << np[n] << endl;

  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#define LL long long
using namespace std;

const int maxn=1e6;
int n,cnt,is_prime[maxn+10],prime[maxn+10],sum[maxn+10];

void init(){
    int i,j;
    for(i=2;i<=maxn;i++){
        if(!is_prime[i]){
        	prime[cnt++]=i;
        }
        for(j=0;j<cnt && i*prime[j]<=maxn;j++){
        	is_prime[i*prime[j]]=1;
        	if(i%prime[j]==0) break;
        }
        sum[i]=cnt;
    }
}

int main(void){
	init();
	while(scanf("%d",&n)!=EOF){
        printf("%d\n",sum[n]);
    }
    return 0;
}

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

void sieve(int n, int arr[])
{
    int i, j;
    for(i=0; i<n; i++)
        arr[i]=1;
    arr[0]=0;
    arr[1]=0;
    for(i=2; i<sqrt(n)+1; i++){
        for(j=i*i; j<=n; j+=i)
            arr[j]=0;
    }
}

int main()
{
    int n, i, ans;
    while(scanf("%d", &n)!=EOF){
        ans=0;
        int arr[n+1];
        sieve(n, arr);
        for(i=0; i<=n; i++)
            if(arr[i]!=0){
                ans++;
            }
        printf("\n%d\n",ans);
        }
    return 0;
}

C++: /*
    ????????°??§???????????¨????????????
*/

#include <stdio.h>
#include <string.h>
#include <ctype.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <limits.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iterator>
#include <vector>
#include <map>
#include <utility>
#define LLU unsigned long long int
#define LL long long int
#define LD long double
using namespace std;
#define LLUmax ULLONG_MAX
#define LLmax LLONG_MAX
#define dmax INT_MAX
#define vd vector<int>
#define vLL vector<long long int>
#define vLLU vector<unsigned long long int> 
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define debug printf("asd\n")
#define debugd(a) printf("--%d\n",a)
#define debugdd(a,b) printf("--%d %d\n",a,b)
#define debugarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i]);printf("\n")
#define newline printf("\n")
#define forin(a,b,c) for(int a=b ; a<c ; a++)
#define forde(a,b,c) for(int a=b ; a<c ; a--)


inline void scd(int &a){scanf("%d",&a);}
inline void scdd(int &a,int &b){scanf("%d %d",&a,&b);}
inline void sctd(int &a,int &b,int &c){scanf("%d %d %d",&a,&b,&c);}
inline void scdlld(long int &a,long int &b){scanf("%I64d %I64d",&a,&b);}
inline void sclld(long long int &a){scanf("%I64d",&a);}

#define scarrd(a,b) for(int index=0 ; index<b ; index++)scanf("%d",&a[index])
#define prdlld(a,b) printf("%I64d %I64d",a,b)
#define prdd(a,b) printf("%d %d",a,b)
#define prd(a) printf("%d",a)
#define prarr(a,b) for(int i=0 ; i<b ; i++)printf("%d ",a[i])
#define iniarr(a,b) for(int i=0 ; i<b ;i++)a[i]=0
#define arr(a,b) int *a=(int *)malloc(b*sizeof(int))
#define llarr(a,b) long long int *a=(long long int *)malloc(b*sizeof(long long int))
#define st(a,b) char *a=(char *)malloc(b*sizeof(char))
#define grav 9.8
#define pi 3.14159265

int prime(int a)
{
	if(a<2)
	return 1;

	for(int i=2 ; (i*i)<=a ; i++)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	int pm[200005];
	int z=0;
	forin(i,2,2000000)
	{
		if(prime(i)==1)
		{
			pm[z]=i;
			z++;
		}
	}
	
	
	while(scanf("%d",&a)!=EOF)
	{
		int d=0;
		forin(i,0,z)
		{
			if(pm[i]>a)
			{
				d=i;
				printf("%d\n",d);
				break;		
			}
		}
	}
	return 0;
}

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

int const MAXN = 999999;

int n;
bool is_prime[MAXN+1];

void check_prime()
{
    for (int i = 0; i <= MAXN; i++) is_prime[i] = true;
    is_prime[0] = is_prime[1] = false;
    for (int i = 2; i <= MAXN; i++) {
        if (!is_prime[i]) continue;
        for (long long j = i * 2; j <= MAXN; j += i)
            is_prime[j] = false;
    }
}

int main()
{
    check_prime();
    while (scanf("%d", &n) != EOF) {
        int res = 0;
        for (int i = 0; i <= n; i++)
            if (is_prime[i]) res++;
        printf("%d\n", res);
    }
    return 0;
}

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

int main(void);
int count_prime_number(int n);

int main(){
	int n;
	int cnt = 0;
	int result[30];

	//while (cnt < 3){
		//std::cin >> n;
	while (std::cin >> n){
		result[cnt] = count_prime_number(n);
		cnt++;
	}

	for (int i = 0; i < cnt; i++){
		std::cout << result[i] << std::endl;
	}

	//while (1);
	return 0;
}


//0..nまでの素数の個数を出力する
//args:数値
//return:素数の個数
int count_prime_number(int n){
	int rtn = 0;

	//2だけ個別チェック
	if (n >= 2){
		rtn++;
	}

	for (int i = 3; i <= n; i+= 2)
	{
		bool is_prime_num = true;
		for (int j = 3; j <= i/*sqrt(i)*/; j+= 2)		//ルートi以上のiの約数はルートi以下のiの約数と対になっているので範囲はルートiまででいい
		{
			if (i % j == 0)
			{
				is_prime_num = false;
				break;
			}
		}

		if (is_prime_num){
			rtn++;

			//デバッグ
			//std::cout << i << std::endl;
		}
	}

	return rtn;
}

C++: #include <iostream>
using namespace std;
int main() {
  long n;
  while (cin >> n) {
    if (n == 1) {
      cout << 0 << endl;
      continue;
    }
    int x = 1;
    if (n == 2) {
      cout << x << endl;
      continue;
    }
    for (int i = 3; i <= n; i += 2) {
      bool prime = true;
      int limit = i / 2;
      for (int j = 2; j <= limit; j++) {
        if (i % j == 0) {
          prime = false;
          break;
        }
      }
      if (prime) x++;
    }
    cout << x << endl;
  }
}