Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [100]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++: #include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <iostream>

#define N 999999L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = (int) sqrt(N);
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide <= rt; divide++){
    if(num[divide] == false) continue;
    for( i = 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] == 1) count++;
    }

    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

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

int main(){
	int cnt=0, x, n, i, j;
	bool flg;
	double rootx;
	int rootintx;
	while(cin>>n){
		cnt=0;
		if(n>=2)cnt++;
		for(x=3;x<=n;x++){
			flg = true;
			if(x==2){
				cnt++;
				continue;
			}
			if(x<2 || !(x%2)){
				continue;
			}
			rootx = sqrt(x);
			rootx = ceil(rootx);
			rootintx = int(rootx);
			for(j=2;j<=rootintx;j++){
				if(!(x%j)){
					flg=false;
					break;
				}
			}
			if(flg)cnt++;
		}
		cout<<cnt<<endl;;
	}
	return 0;
}

C++: #include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <time.h>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <iomanip>

#define out freopen("output.txt", "w", stdout);
#define in freopen("input.txt", "r", stdin);
#define clr(arr, key) memset(arr, key, sizeof arr)
#define pub push_back
#define pob pop_back
#define infinity 2147483647
#define LL long long
#define Pi acos(-1)
#define SZ 1000010

///int col[8] = {0, 1, 1, 1, 0, -1, -1, -1};
///int row[8] = {1, 1, 0, -1, -1, -1, 0, 1};
///int col[4] = {1, 0, -1, 0};
///int row[4] = {0, 1, 0, -1};

using namespace std;
bool primes[1100000];
int sieve(int n)
{
    int i, j;
    primes[1] = 1;
    for(i = 4; i <= 1100000; i += 2)
        primes[i] = 1;
    for(i = 3; i < 1100000 / i; i += 2)
    {
        if(primes[i] != 1)
        {
            for(j = 2; j * i < 1100000; j++)
                primes[i * j] = 1;
        }
    }
    int cnt = 0;
    for(i = 2; i <= n; i++)
        cnt += !primes[i];
    return cnt;
}

int main()
{
    int n;
    cin >> n;
    cout << sieve(n) << endl;
    return 0;
}

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

int prime(int num){

	if(num<2){
		return 0;
	}else if(num==2){
		return 1;
	}else if(num%2==0){
		return 0;
	}
	
	for(int s=3; pow(s,2)<=num; s+=2){
		if(num%s==0){
			return 0;
		}
	}
	
	return 1;
}

int main(){
	int num, count=0;
	
	cin >> num;
	
	for(int i=0; i<=num; i++){
		if(prime(i)==1){
			count++;
		}
	}
	
	cout << count << endl;
	
	return 0;
}

C++: #include<cstdio>
using namespace std;
const int MAX = 1200000;
bool prime[MAX];
int solve(int n){
  int cnt = 1;
  if(n == 1)
    return 0;
  else if(n == 2)
    return 1;
  else{
    for(int i = 3 ; i <= n ; i++){
      if(prime[i])
        cnt++;
    }
  }
  return cnt;
}
int main(){
  for(int i = 0 ; i < MAX ; i++)
    prime[i] = true;
  prime[0] = prime[1] = false;
  for(int i = 4 ; i < MAX ; i += 2)
    prime[i] = false;
  for(int i = 3 ; i < MAX ; i += 2){
    if(prime[i]){
      for(int j = i * 2 ; j < MAX ; j += i)
        prime[j] = false;
    }
  }
  int n;
  while(scanf("%d",&n) != EOF){
    printf("%d\n",solve(n));
  }
}

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

class PrimeNumbers
{
public:
	vector<int> primeNumbers;

	PrimeNumbers()
	{
		this->createPrimeNumbers();
	}
	
	int answer(int N)
	{
		int result = 0;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(*it <= N)result++;
			else break;
		}
		return result;
	}

	bool checkOf(int n)
	{
		if(n % 2 == 0)return false;

		bool prime = false;
		for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
		{
			if(n == *it)
			{
				prime = true;
				break;
			}
		}
		return prime;
	}

	void createPrimeNumbers()
	{
		int max_number = 999999+1;
		this->primeNumbers = vector<int>();
		this->primeNumbers.push_back( 2 );
		for(int i = 3; i < max_number; i += 2)
		{
			bool prime = true;
			for(auto it = this->primeNumbers.begin(); it != this->primeNumbers.end(); it++)
			{
				if(i % *it == 0)
				{
					prime = false;
					break;
				}
			}
			if(prime)
			{
				this->primeNumbers.push_back(i);
			}
		}
	}

};

int main()
{
	int N;
	PrimeNumbers pn = PrimeNumbers();
	while(cin >> N)
	{
		cout << pn.answer(N) << endl;
	}
	return 0;
}

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

int main(){
int unti[100001] = {0};
fill(unti,unti + 100001,0);
for(int n = 2;n < 100000;n++){
if(unti[n] == 0)
{
for(int a = 2;(a * n) < 100000;a++)
{unti[a * n]++;}}}
int b;
while(cin >> b ){
int cnt = (count(unti,unti+b+1,0) - 2);
cout << cnt << endl;
}
return 0;
}

C++: #include<iostream>
using namespace std;
 
__forceinline int isPrime(int n){
	//sieve of Eratosthenes
	if(n==2) return 1;
	if(n%2==0 || n<2){
		return 0;
	}

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

}

//0009
int main()
{
	int n;
 
	while(cin >> n){
		int cnt = 0;
		for(; n>1; n--){
			if(isPrime(n))
				++cnt;
		}
		cout << cnt << endl;
	}
  return 0;
}

C++: #include<iostream>
#include<cstdio>
#include<fstream>
#include<cstdlib>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<cstring>
#include<ctime>
#include<climits>
#include<ctype.h>
#include<cmath>
#include<algorithm>
using namespace std;
typedef long long ll;
#define PI acos(-1.0)
#define eps 1e-12
const int INF_INT = 2147483647;
const ll INF_LL = 9223372036854775807LL;
const ll N = 1e6+1;
const int MOD = 1e9+7;
bool flag = true;
int prime[N];
bool check[N]{0};
int main()
{
	//    freopen("C:\\Users\\Administrator\\Desktop\\in.txt","r",stdin);
	//    freopen("C:\\Users\\Administrator\\Desktop\\out.txt","w",stdout);
	//%%%llaa
    int i,j,n,tot=0;
    for(i=2;i<N;i++)
    {
        if(!check[i])
        {
            prime[tot++]=i;
            for(j=i+i;j<N;j+=i)
                check[j]=1;
        }
    }
    int p=30;
    while(~scanf("%d",&n)&&p)
    {
        p--;
        int num=0;
        i=0;
        while(prime[i++]<=n)
            num++;
        printf("%d\n",num);
    }
	return 0;
}


/*

*/

C++: #include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int keta(int x){
	int i=0;
	while (x/pow(10,i)>=1){
		i++;
	}
	if (x==0){
		return 1;
	}
	else
	return i;
	}


int main(){
int n;
while (cin>>n){
	int yakusu=0;
	for (int i=2;i<=n;i++){
		bool flag=true;
		for (int j=2;j<i-1;j++){
			if(i%j==0){
				flag=false;
			}
		}
		if (flag){
		yakusu++;
		}

	}
cout<<yakusu<<endl;
}
	}