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<iostream>
#include<string>
int main(){for(int m,n,o,c,d,e,i;!(std::cin>>n).eof();){if(n<3)e=n>1;else{bool*v=new bool[c=(n&1?n:--n)/2+1];std::memset(v,1,c);for(i=m=e=1;i<c;i++){for(m=i;m<c&&!v[m];)m++;if(m==c)break;e++;for(d=o=m*2+1;d<n+1;d+=o*2)v[d/2]=0;if(n<o*o)break;}for(i=1;i<c;)e+=v[i++];delete[]v;}printf("%d\n",e);}}

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

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    int a[30]={0};
    int b[30]={0};
    int num = 0;
    int max =0;
    
    
    while(scanf("%d",&n)!=EOF){
        a[num]=n;
        if(max<n){
            max=n;
        }
        num++;
    }
    
    int temp = 0;
    for(int i=2; i<=max; i++ ){
        temp+=sosuu(i);
        for(int j=0; j<num; j++ ){
            if(i==a[j]){
                b[j]=temp;
            }
        }
    }
    
    for(int j=0; j<num; j++ ){
        printf("%d\n",b[j]);
    }
    
    
}

int sosuu(int n){
    if(n==2){
        return 1;
    }else{
        int temp=1;
        for(int i=0; i<n; i++){
            temp=temp*2;
        }
        if(temp%n!=2%n){
            return 0;
        }
        return 1;
    }
}

C++: #include<stdio.h>
#include<math.h>
int judge(int x)
{
	if (x == 2)
		return 1;
	for (int i = 2; i < sqrt(x) + 1; i++)
		if (x%i == 0)
			return 0;
	return 1;
}
int main()
{
	int a, num;
	while (scanf("%d", &a) != EOF)
	{
		num = 0;
		for (int i = 2; i <= a; i++)
			if (judge(i))
				num++;
		printf("%d\n", num);
	}
	return 0;
}

C++: #include<iostream>

using namespace std;



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

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

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

using namespace std;

int main()
{
	int n,ans,flag;

	while(scanf("%d",&n)!=EOF){
		ans=0; 
		for(int i=2;i<=n;i++){
			flag=1;
			for(int j=2;j*j<=i;j++){
				if(i%j==0) {flag=0;break;}
			}
			if(flag) ans++;
		}
		cout<<ans<<endl;
	}

	return 0;
}

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

int main(){
  int a,j,cou;
  while(cin>>a){
    cou=0;
    for(int i=2;i<=a;i++){
      if(i==2){
	cou++;
	continue;
      }
      else if(i%2==0)continue;
      for(j=3;j*j<=i;j+=2)if(i%j==0)break;
      if(j*j>i)cou++;
    }
    cout <<cou<<endl;
  }
  return 0;
}

C++: #include <iostream>

bool divisible( int u, int v )
{
    return (u % v) == 0 ? true : false;
}

int num_divisors( unsigned int start, unsigned int end )
{
    if ( start == end ) return 1;
    return divisible( end, start ) + num_divisors( start+1, end );
}

int no_of_divisor( unsigned int n )
{
    return num_divisors( 1, n );
}

bool is_prime( unsigned int n )
{
    return (no_of_divisor(n) == 2);
}

int count_prime( unsigned int n )
{
    int count = 0;
    for ( unsigned int i = 1; i <= n; ++i )
    {
        if ( is_prime(i) ) ++count;
    }
    return count;
}

int main()
{
    int n;
    while( std::cin >> n)
        std::cout << count_prime(n) << std::endl;
    return 0;
}

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

#define maxPN 100000
#define PNs  1000100
int countPN = 0, countPNs = 0;
int PrimeNum[maxPN], temp;
bool PN[PNs];

bool IsPrimeNumber(int x);

void PrimeN(){
	int i, j;
	PrimeNum[0] = 2;
	PN[2] = true;PrimeNum[countPN++] = 2;
	PN[3] = true;PrimeNum[countPN++] = 3;
//	PN[5] = true;PrimeNum[countPN++] = 5;
	
	for(i = 6; i  < PNs;i+=6){
		if(IsPrimeNumber(i-1)){
			PrimeNum[countPN++] = i-1;
			PN[i-1] = true;//cout<<i-1<<endl;
		}
		if(IsPrimeNumber(i+1)){
			PrimeNum[countPN++] = i+1;
			PN[i+1] = true;//cout<<i+1<<endl;
		}
		countPNs = i+1;//cout<<i-1<<" "<<PN[i-1]<<endl;
	}
}

bool IsPrimeNumber(int x){
	//if(x == 2 || x == 3) return true;
	//if(x <= 4 || x%2 == 0 || x%3 == 0)   return false;
	//if(x < countPNs) return PN[x];
	for(int i = 0; PrimeNum[i] * PrimeNum[i] <= x; i++)
		if(x%PrimeNum[i] == 0)return false;
	return true;
}


int main(){
//	clock_t start, end;
	int n = true, counta;
//	start = clock();
	PrimeN();
	cout<<PrimeNum[countPN-1]<<" "<<countPNs<<endl;
//	cout<<clock()-start<<"ms"<<endl;
	
	while(cin>>n){
		counta = 1;
		
		
		//cout<<(IsPrimeNumber(n)?"yes":"no")<<endl;
	//	start = clock();
		//cout<<IsPrimeNumber(n)<<endl;
		for(int i = 1; i <= n; i+=2){
			if(PN[i])counta++;
		//	cout<<i<<" "<<PN[i]<<endl;
		}
		if(n == 1) counta = 0;
		cout<<counta<<endl;
	//	cout<<clock()-start<<"ms"<<endl;
	}
	return 0;
}

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

bool check(int in){
	for (int i = 3; i<=sqrt(in); i+=2){
		if (in % i == 0)
			return false;
	}
	return true;
}

int PrimeNumber(int in){
	int count = 0;
	if (in > 2)	count++;
	for (int i = 3; i <=in; i+=2){
		if (check(i))	count++;
	}

	return count;
}

int main(){
	int in;
	while (cin >> in, !cin.eof()){
		cout << PrimeNumber(in) << endl;
	}
}

C++: #include<stdio.h>
int main()
{
    long long n;
    while(scanf("%lld",&n)==1)
    {
       long long i,j,k,s=0;
       for(i=2;i<=n;i++)
    {

        k=0;
        if(i%2==0&&i!=2)
            k=1;
      for(j=3;j*j<=i&&k==0;j+=2)
      {
          if(i%j==0)
          {
              k=1;
              break;
          }
      }
       if(k==0)
          {
             ++s;
          }
    }
        printf("%lld\n",s);
    }
}

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

int main(void)
{
	int num, cnt;
	unsigned int i, j;
	int data_num;
	unsigned int sq_num;
	unsigned int *prime;

	scanf("%d", &num);

	sq_num = (int)sqrt((double)num);
	prime = (unsigned int*)malloc(sizeof(unsigned int) * num);

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

	prime[0] = 0;
	for (i = 1; i < sq_num; i++) {
		if (prime[i] == 1) {
			for (j = (i+1); (i+1) * j <= num; j++) {
			prime[(i+1) * j - 1] = 0;
			}
		}
	}

	cnt = 0;
	for (i = 0; i < num; i++) {
		if (prime[i] == 1) {
			cnt++;
			//printf("%d", i + 1);
		}
	}

	printf("%d\n", cnt);

	free(prime);

	return 0;

}

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

int main(){
 bool is_prime[1000000]; //?´???°???????????¨

 is_prime[0] = is_prime[1] = false;

 for(int i=2; i<1000000; i++){
  is_prime[i] = true;
 }

 for(int i=2; i*i<1000000; i++){
  if(is_prime[i]){
   for(int j=i*i; j<1000000; j+=i){
    is_prime[j] = false;
   }
  }
 }

 int n_prime[1000000]; //?´???°????????°?????¨

 int cnt = 0;

 for(int i=0; i<1000000; i++){
  if(is_prime[i]){
   cnt++;
  }
  n_prime[i] = cnt;
 }

 while(true){
  int n;
  cin >> n;

 if(cin.eof()) break;

 cout << n_prime[n] << endl;
 }

 return 0;
}

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



int main(){
	int i , j , n , pn;
	
	while(cin>>n){
		pn=1;
		for(i=3 ; i<=n ; i++){
			for (j=2 ; j<i ; j++){
				if (i%j==0) goto skip;
			}
			pn++;
			skip:;
		}
		if(n==0 || n==1 ) {
			cout << 0 << endl;
		} else {
			cout << pn << endl;
		}
	}
	return 0;
}