Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var resultArr [31]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<vector>
#include<cmath>
using namespace std;

const int MAX=1000000;
int N;
vector<int>ip(1000001,1);
int ans=0;




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


	while(cin>>N){

		for(int i=0;i<=N;i++){
			if(ip[i])ans++;
		}
	

		cout<<ans<<endl;
		ans=0;

	}


	
}

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

using namespace std;

const int INF=1000000;

int main()
{
    int pri[INF];
    int res[INF];
    for(int i=0;i<INF;i++)
        pri[i]=0;
    for(int i=2;i*i<INF;i++)
    {
        if(pri[i]==0)
        {
            for(int j=i*2;j<INF;j+=i)
            {
                pri[j]=1;
            }
        }
    }
    int n=0;
    for(int i=2;i<INF;i++)
    {
        if(pri[i]==0)
            n++;
        res[i]=n;
    }
    int C;
    while(cin>>C)
    {
        cout<<res[C]<<endl;
    }
}

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

bool prime[1000000];

int main()
{
    int i,j,k,l,m,n;
    int count;
    while(cin>>n)
    {
        memset(prime,0,sizeof(prime));
        prime[1]=1;
        prime[2]=0;

        count=0;

        for(j=2;j*j<=n;j++)
        {
            if(prime[j]==0)
            {
                for(k=2;k*j<=n;k++)
                {
                   prime[j*k]=1;
                }
            }
        }
        for(i=1;i<=n;i++)
        {
            if(prime[i]==0)
            count++;
        }
        cout << count << endl;
    }
    return 0;
}

C++: #include<bits/stdc++.h>
using namespace std;

int main(){
  int n,i;
i=0;
vector<int> an(1000000),as(1000000);
an[0]=2;
  for(int j=3;j<1000000;j++){
   for(int u=0;u<1000000;u++){
if(an[u]==0){
an[u]=j;
break;
}
if(j%an[u]==0){
break;
}
else{
continue;
}
}
}
   for(int u=1;u<1000000;u++){
if(u==an[i]){
as[u]=as[u-1]+1;
}
else{
as[u]=as[u-1];
}
}
for(int i=0;i<30;i++){
   cin>>n;
cout<<as[n]<<endl;
}

C++: #include <iostream>

int main() {
	int n;
	while (std::cin >> n)
	{
		int c = 0;
		for (int i = 2; i <= n; ++i) {
			int j = 2;
			while (i%j)
			{
				++j;
			}
			if (i == j) {
				++c;
			}
		}
		std::cout << c << std::endl;
	}
	}

C++: #include <iostream>
#include <list>
#include <algorithm>
 
using namespace std;
 
int main() {
int n;
 
while(!cin.eof()) {
cin >> n;
list<int> search_list(n-1);
list<int> prime_number;
while(n!=1) {
search_list.push_front(n);
n--;
}
while(!search_list.empty()) {
int m = search_list.front();
prime_number.push_back(m);
search_list.pop_front();
list<int>::iterator it = search_list.begin();
while(it!=search_list.end()) {
if((*it % m) == 0){
it = search_list.erase(it);
continue;
}
it++;
}	
}
cout << prime_number.size()-1 << endl;
}
}

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

using namespace std;



bool Prime(int n)
{
	if((n==1)||(n==0))
	{
		return false;
	}
	for(int i=2;i<=(int)sqrt((double)n);++i)
	{
		if(n%i==0)
		{
			return false;
		}
	}
	return true;
}

int main()
{
	int n;
	while(cin>>n)
	{
		int count = 0;
		for(int i=0;i<=n;++i)
		{
			if(Prime(i))
			{
				++count;
			}
		}
		cout<<count<<endl;
	}
	return 0;
}

C++: //--------------------------------------------------template----------------------------------------//
//c
#include <stdio.h>
#include <time.h>
#include <math.h>
//c++
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <sstream>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <complex>
#include <cmath>
//c++11
#include <tuple>
#define all(c) ((c).begin(),(c).end())
#define rall(c) (c).rbegin(),(c).rend()
//#define sort(v,n) sort(v,v+n)
//#define vsort(v) sort(v.begin(),v.end())
#define vvsort(v) sort(v.rbegin(),v.rend())
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
//---------------------------------------------------------------------------------------------//
int n;

bool is_prime(int a) {
	int now = 2;
	while (now*now <= a) {
		if (a%now == 0)return 0;
		else now++;
	}
	return 1;
}


int main() {
	while (cin >> n) {
		ll ans = 0;
		bool a[1000001];
		for (int i = 2; i <= n; i++) {
			if (a[i] == 1)continue;
			if (is_prime(i))ans++;
			else {
				for (int j = i; j <= n; j += i) {
					a[j] = 1;
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

C++: #include <stdio.h>

int main()
{
    int n, j, sum = 0, flag = 0;


    while(scanf("%d", &n) == 1)
    {
        for(j = 2; j <= n; j++)
        {
            if(j % 2 == 0 && j != 2)
            {
                flag = 1;
            }
            else if(j % 3== 0 && j != 3)
            {
                flag = 1;
            }
            else if(j % 5== 0 &&  j != 5)
            {
               flag = 1;
            }
            else if(j % 7 == 0 && j != 7)
            {
               flag = 1;
            }
            if(flag == 0)
            {
                sum = sum + 1;
            }
            flag = 0;

        }
        printf("%d\n", sum);
        flag = 0;
        sum = 0;
    }
    return 0;
}

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

using namespace std;

int main()
{
	int n;
	vector<int> prime;
	
	for (int i = 3; i < 10000000; i += 2){
		int j;
		for (j = 1; j < prime.size(); j++){
			if (i % prime[j]){
				break;
			}
		}
		if (j >= prime.size()){
			prime.push_back(i);
		}
	}
	while (scanf("%d", &n) != EOF){
		int count;
		
		for (count = 1; prime[count - 1] < n; count++);
		if (n >= 2){
			count++;
		}
		printf("%d\n", count);
	}
	
	return 0;
}

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

#define MAX 1000000

int main()
{
	int n;
	int prime[MAX];

	prime[0] = prime[1] = false;

	for (int i = 2; i < MAX; i++){
		prime[i] = true;
	}

	for (int i = 0; i < MAX; i++){
		for (int j = i * i; j < MAX; j += i){
			prime[j] = false;
		}
	}

	for (int i = 0; i < MAX; i++){
		prime[i + 1] += prime[i];
	}

	while (scanf("%d", &n) != EOF){
		printf("%d\n", prime[n]);
	}

	return (0);
}

C++: #include <iostream>
#include <vector>
using namespace std;
int main() {
  vector<int> prime_list;
  bool flag;

  prime_list.push_back(2);
  for (int i = 3; i < 50; i++) {
    for (int j = 0; j < prime_list.size(); j++) {
      if(i%prime_list[j] == 0) {
        flag = false;
        break;
      } else {
        flag = true;
      }
    }
    if (flag) {
      prime_list.push_back(i);
    }
  }

  int data, count;
  while(cin >> data) {
    for (int i = 0; i < prime_list.size() && prime_list[i] <= data; i++, count = i);
    cout << count << endl;
  }
}

C++: #include <cstdio>
#include <stdio.h>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;

int main(){
	int max,n[1000],c = 0,check;
	while(cin >> max){
		c = 0;
		for(int i = 2;max >= i;i++){
			check = 0;
			for(int iii = 1;c >= iii;iii++){
				if(i % n[iii] == 0){check = 1;break;}
			}
			for(int ii = 2;i > ii and check == 0;ii++){
				if(i % ii == 0){check = 1;break;}
			}
			if(check == 0){c++;n[c] = i;}

		}
		cout << c << endl;
	}



}