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++: #include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <numeric>
#include <ctype.h>
#include <cstdlib>
#include <string.h>
#include <cmath>
#include <cstdio>





using namespace std;

bool isPrime(int num);

int main()
{
	int input, count = 0;

	while (cin >> input)
	{
		count = 0;

		for (int i = 2; i <= input; i++)
		{
			if (isPrime(i))
			
				count++;
	
		}
		cout << count << endl;
	}

	
}

bool isPrime(int num)
{
	if (num < 2) return false;
	else if (num == 2) return true;
	else if (num % 2 == 0) return false;
	

	double sqrtNum = sqrt(num);

	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
			return false;
	}

	return true;
}

C++: #include <iostream>
using namespace std;
int main()
{
	int n;
	while(cin >> n)
	{
		bool* num=new bool[n+1];
		num[0]=num[1]=true; for(int i=2;i<=n;i++) num[i]=false;
		int ans=0;
		for(int i=2;i<n;i++)
		{
			if(num[i]==false)
			{
				for(int j=i*2;j<=n;j+=i) num[j]=true;
			}
		}
		for(int j=2;j<=n;j++) if(num[j]==false) ans++;
		cout << ans << '\n' ;
		delete[] num;
	}
}

C++: #include <string>
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <iomanip>


using namespace std;

typedef unsigned long long ull;

int main(void) {
	vector<int> dp = vector<int>(1000000, 0);
	int tmp = 0;
	for(int i = 2; i < 1000000; i++){
		if(dp[i] != 0)continue;
		dp[i] = ++tmp;
		for(int j = i * 2; j < 1000000; j += i){
			dp[j] = -1;
		}
	}
	int n;
	while(cin >> n){
		while(dp[n] == -1) n--;
		cout << dp[n] << endl;
	}
}

C++: #include <iostream>
#include <cmath>
using namespace std;
/*
bool isPrime(int n) {
  for(int i = 2; i < n; ++i) {
	if(n % i == 0) return false;
  }
  return true;
}
*/

bool isPrime(int x) {
  if (x == 2) return true;

  if (x < 2 || x % 2 == 0) return false;

  int i = 3;
  while(i <= sqrt(x)) {
	if(x % i == 0) return false;
	i += 2;
  }
  return true;
}

int main() {
  int n;
  while(cin >> n) {
	int cnt = 0;
	for(int j = 2; j <= n; ++j) {
	  if(isPrime(j)) cnt ++;
	}
	cout << cnt << endl;
  }
  return 0;
}

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

using namespace std;

bool p[3000000];
vector<int> prime;

void init(){
    memset(p,1,sizeof(p));
    p[0] = p[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(!p[i]) continue;
        for(long long j = 1LL*i*i; j <= 1000000; j += i)
            p[j] = false;
        prime.push_back(i);
    }
}

int CntPrime(int n){
    vector<int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
    if( *it > n) it--;
    return (it - prime.begin() + 1);
}

int main(){
    init();
    int n;
    while(cin >> n){
        cout << CntPrime(n)<< endl;
    }
    return 0;
}

C++: //include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <complex>
#include <math.h>
using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(long i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const long double EPS = 1e-12;
const double INF = 1e12;

LL gcd(LL a,LL b){
	if(b==0)return a;
	return gcd(b,a%b);
}

int main(){
	long n;
	while(cin>>n){
		long cnt=0;
		for(long i=2;i<=n;i++){
			bool flag=true;
			for(long j=2;j*j<=i;j++)if(i%j==0)flag=false;
			if(flag)cnt++;
		}
		cout<<cnt<<endl;
	}
	return 0;
}

C++: #include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <stdio.h>

using namespace std;

int main()
{
	vector<int> p;
	int flag,n,ans;
	
	p.push_back(2);	p.push_back(3);	p.push_back(5);

	for(int i=7;i*i<999999;i++){
		flag=1;
		for(int j=0;j<p.size();j++){
			if(i%p[j]==0){flag=0;break;}
		}
		if(flag) p.push_back(i);
	}

	while(scanf("%d",&n)!=EOF){
		ans=0;
		for(int i=0;p[i]<=n;i++) ans++;
		cout<<ans<<endl;
	}


	return 0;
}

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

using namespace std;

int SUUZI[1000000];

int a=0,b,d,f,n,c=0;
double buffer;

int main(){

	for(d=0;d<1000000;d++){SUUZI[d]=1;};
	
		for(a=3;a<1000000;a++){
			buffer=a;
				for(b=2;1;b++){
					if(a%b==0){SUUZI[a]=0;break;};
					if(b>sqrt(buffer)){SUUZI[a]=1;break;};
				};
};


cout<<c<<endl;

while(cin>>n){
	c=0;
for(d=0;d<=n;d++){c+=SUUZI[d];};

cout<<c-2<<endl;

};
return 0;

}

C++: #include <iostream>
using namespace std;
int s[10000],m[1000000],i,j,n=0;
int main() {
	for (i=2; i<100000 ; i++) {
		if (m[i]==0) {
			s[n++]=i;
			for (j=i; j<1000000; j+=i) m[j]=1;
		}
	}
	while(cin >> i) {
		for (j=0;s[j]<=i && j<n;j++) ;
		cout << j << endl;
	}
cin >> j;
return 0;
}

C++: #include<stdio.h>

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

	while(scanf("%d",&data) != EOF)
	{
		if(data<=1)
		   kai=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+=1;
				}
			}
		}
		printf("%d",kai);
		kai=0;
	}

  return 0;
}

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

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