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>
int isprime(int x){
	int i;
	if(x == 2){
 		return 1;
	}
  	if(x<2||x%2==0){
		return 0;
	}
	i = 3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			if(isprime(i)){
				c++;
			}
		}
		printf("%d\n",c);
	}
	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;
	
	if(a%2==0)
	return 0;
	
	for(int i=3 ; (i*i)<=a ; i+=2)
	{
		if(a%i==0)
		return 0;
	}
	
	return 1;
}

int main()
{
	int a;
	while(scanf("%d",&a)!=EOF)
	{
		int d=0;
		forin(i,2,a+1)
		{
			if(prime(i)==1)
			d++;
		}
		printf("%d\n",d);
	}
	return 0;
}

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

int main()
{int c,g;
	bool prime[30] ;
	for(int i = 0 ; i <=30 ; i++ )
	prime[i] = true ;
	prime[0] = prime[1] = false ;
	for(int i = 2 ; i <=30 ; i++){
		if(prime[i]){
					for(int j = i * i ; j <=30 ; j += i )
					prime[j] = false ;
		}
	}


while(cin>>g){
	c=0;

	for(int i = 0 ; i <= g ; i++){
		if(prime[i])
		c++;
	}
cout<<c<<endl;
}
}

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

int main(){
	bool arr[1000003];
	int n;
	while(cin >> n){
		int count = 0;
		for(int i = 2; i < 1000003; i++) arr[i] = true;

		for(int i = 2; i < sqrt(n); i++){
			if(arr[i] == true) {
				for(int j = 0; i * (j + 2) <= n; j++) {
				arr[i * (j + 2)] = false;
				}
			}
		}
		for(int i = 2; i <= n; i++){
			if(arr[i] == true) count++;
		}

		cout << count << "\n";
	}
}

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

using namespace std;

vector<int> a(1000000, 1);

int main(void)
{
	a[0] = a[1] = 0;
	for (int i = 2; i < 1000000; i++) {
		if (a[i]) {
			for (int j = i * 2; j < 1000000; j += i) {
				a[j] = 0;
			}
		}
	}
	for (int i = 1; i < 1000000; i++) {
		a[i] += a[i - 1];
	}

	int n;
	while (scanf("%d", &n) != EOF) {
		cout << a[n] << endl;
	}

	return 0;
}

C++: #include <iostream>
#include <vector>
#include <set>
#include <cmath>
std::vector<int> PRIMES;

void init_primes(int max)
{
  if (max < 2) return;
  std::set<int> candidate;
  PRIMES.push_back(2);
  for (int i = 3; i < max; i+=2) {
    candidate.insert(i);
  }
  for (int i = 3; i < sqrt(max); i+=2) {
    auto it = candidate.find(i);
    if (it != candidate.end()) {
      PRIMES.push_back(i);
      int del_num = i;
      while (del_num < max) {
        it = candidate.find(del_num);
        if (it != candidate.end()) candidate.erase(it);
        del_num += i;
      }
    }
  }
  for (auto it = candidate.begin(); it != candidate.end(); ++it) {
    PRIMES.push_back(*it);
  }
}

int main()
{
  const int max = 1000000;
  init_primes(max);
  int i;
  while (std::cin >> i) {
    auto it = PRIMES.begin();
    int n = 0;
    while (*it <= i && it != PRIMES.end()) {
      n++;
      it++;
    }
    std::cout << n << std::endl;
  }
  return 0;
}

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

int main(){

	int n,count;
	while(cin>>n){
		count=0;
		for(int i=2; i<=n; i++){
			int num = 0;
			for(int j=1; j<=i ;j++){
				if(i%j==0) num++;
			}
			if(num==2){
				count++;
			}
		}
		cout << count << endl;
	}
    return 0;
}

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

bool dec(int i, int prime[]) {
  for (int j = 0; prime[j] != 0; j++) {
    if (i % prime[j] == 0) {return false;}
  }
  return true;
}

int main() {
  int n;
  while (cin >> n) {
    int count = 0;
    int prime[1000000];
    for (int i = 0; i < 1000000; i++) {
      prime[i]=0;
    }
    if (n >= 2) {
      prime[0] = 2;
      count++;
    }
    for (int i = 3; i <= n; i += 2) {
      if (dec(i, prime)) {
	prime[count] = i;
	count++;
      }
    }
    cout << count << endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define fir first
#define sec second
#define ub upper_bound
#define lb lower_bound
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;

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

signed main(){
  int p[100006];
  loop(i,2,100001){
    if(Is_Prime(i))p[i]=1;
  }
  rep(i,100001)p[i+1]+=p[i];
  int n;
  while(cin>>n){
    cout<<p[n]<<endl;
  }
  return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;
int N, i, j, H[1000001];
bool A[1000001];
int main () {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	memset(A,true,1000000*sizeof(bool));
	A[1]=false;
	for (i=2;i<1000;i++) {
		if (A[i]) {
			for (j=i;j*i<1000000;j++) {
				A[i*j]=false;
			}
		}
	}
	H[1]=0;
	for (i=2;i<1000000;i++) {
		H[i]=H[i-1]+A[i];
	}
	while (cin>>N) {
		cout<<H[N]<<endl;
	}
}