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<cmath>
#include<cstdio>

using namespace std;

int main(void){
	long n;
	int a;
	while(scanf("%d", &n) != EOF){
		bool p[1000001];
		for(int i = 2; i <= n; i++)
			p[i] = true;
		for(int i = 2; i < sqrt(n); i++){
			if(p[i]){
				for(int j = 0; i*(j+2) <= n; j++){
					p[i*(j+2)] = false;
				}
			}
		}
		int count = 0;
		for(int i = 2; i <= n; i++){
			if(p[i]) count++;
		}
		cout << count << endl;
	}
	return 0;
}

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


int main()
{

	int i,n,count;
	deque<int> sosu;
	while(cin >> n){
		if( n <= 2 ) {
			if( n == 2 ) {
				count = 1;
			}
			else 
				count = 0;
		}
		else {
			sosu.push_back(2);
			for( i = 3; i <= n ; i+=2 ) {
				bool flg = false;
				deque<int>::iterator it;
				for(it = sosu.begin(); it != sosu.end(); it++ ) {
					if( i % *it == 0 )
						break;
					if( i < 2 * (*it) ){
						flg = true;
						break;
					}
				}				
				if( flg == true ) {
					sosu.push_back( i );
				}
			}							
			count = sosu.size();
		}
		cout << count << endl;
	}
			
	return 0;
}

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


int main()
{

	int i,n,count;
	deque<int> sosu;
	while(cin >> n){
		sosu.clear();
		if( n <= 2 ) {
			if( n == 2 ) {
				count = 1;
			}
			else 
				count = 0;
		}
		else {
			sosu.push_back(2);
			deque<int>::iterator it;
			bool flg;
			for( i = 3; i <= n ; i+=2 ) {
				flg = false;	
				for(it = sosu.begin(); it != sosu.end(); it++ ) {
					if( i < 2 * (*it) ){
						flg = true;
						break;
					}
					if( i % *it == 0 )
						break;
				}				
				if( flg == true ) {
					sosu.push_back( i );
				}
			}							
			count = sosu.size();
		}
		cout << count << endl;
	}
			
	return 0;
}

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

int main(int argc, char *argv[]) {
	using namespace std;
	
	int line;
	while (EOF != fscanf(stdin, "%d", &line)) {
		vector<bool> sieve(line, true);
		int prmCount = 0;

		for (int i = 2; i < line; i++) {
			if (sieve[i]) {
				prmCount++;
				for (int j = i+i; j < line; j+=i) {
					sieve[j] = false;
				}
			}
		}
		printf("%d\n", prmCount);
	}
	

	return 0;
}

C++: #include<stdio.h>
int main(void) {
   int n = 1000, i, l, s[1000];
   while ( n ) { s[n] = 0; n--; }
   s[1] = 1;
   for ( i = 2; i < 1000; i++ ) {
      if ( s[i] == 0 ) {
         for ( l = 2; l <= 1000 / i; l++ ) s[ i * l] = 1;
      }
   }
   for ( i = 1; i < 1000; i++ ) printf("s[%d]:%d\n", i, s[i]);
   return 0;
}

C++: #include<iostream>
#include<math.h>
using namespace std;
bool n[1000000]={0};
bool prime(int n){
	for(int i=2;i<=sqrt ((double)n);i++){
		if(n%i==0)return false;
	}
	return true;
}
int main(){
	for(int k=2;k<=999999;k++){
		if(prime(k))n[k]=true;
	}


	int a,sum=0;
	while(cin>>a){
	for(int j=2;j<=a;j++){
		if(n[j])sum++;
	}
	cout<<sum<<endl;
	sum=0;
	}
}

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

int main(){
	int n;
	int sosu[100000];
	int snum;
	bool judge;

	sosu[0] = 2;

	while(cin >> n){
		snum = 0;
		for(int i = 3; i <= n; i++){
			judge = true;
			for(int j = 0; j <= snum; j++){
				if(i%sosu[j] == 0){
					judge = false;
					break;
				}
			}
			if(judge == true){
				snum ++;
				sosu[snum] = i;
			}
		}
		cout << snum + 1 << endl;
	}



	return(0);
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int prime(int);
int main(){
    int a,n;
    while ( cin >> a){
        n=0;
        for (int i=2;i<a;i++){
            if (prime(i)!=0){
                n++;
            }
        }
        cout << n << endl;
    }
}


int prime(int x){
    int y=0;
    if (x==1)
        return 1;
    for (int i=2;i<x/2+1;i++){
        if(x%i==0)
            return 0;
    }
    return x;
}

C++: #define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <vector>
#include <list>
#include <algorithm>

using namespace std;

int main(int argc, char const* argv[])
{
    vector<int> nl;
    int mx = 0;
    int n;
    while (scanf("%d ", &n) != EOF) {
        nl.push_back(n);
        mx = max(mx, n);
    }

    double r = sqrt(mx);

    list<int> sl;
    vector<int> primes;

    for (int i = 2; i <= mx; i++) {
        sl.push_back(i);
    }

    while (sl.front() <= r) {
        int p = sl.front();
        primes.push_back(p);
        sl.pop_front();

        auto i = sl.begin();
        while(i != sl.end()){
            if(*i % p == 0){
                i = sl.erase(i);
            }
            else {
                i++;
            }
        }
    }

    for (auto&& i : sl) {
        primes.push_back(i);
    }

    for (auto&& n : nl) {
        auto p = upper_bound(primes.begin(), primes.end(), n);
        printf("%d\n", p - primes.begin());
    }

    return 0;
}

C++: #include<stdio.h>
#include<float.h>
#include<vector>


vector<int> primes;
int ref_max=2;

int makePrimenumbers(int a){
	if(a<ref_max)return 0;

	temp = ref_max;
	ref_max=a;
	int i,k,isp=1;

	for(k=temp;k<ref_max;k++){
		for(i=0;i<primes.size();i++){
			if(k%primes[i]==0){
				isp=0;
				break;
			}
		}
		if(isp==1){
			primes.push_back(k);
		}
		isp=1;
	}
	return 0;
}

int countprime(int a){
	int i;
	for(i=0;i<prime.size();i++)
		if(a<prime[i])
			break;
	return (i);
}

int main(void)
{
	int result;
	while(scanf("%d",&a)!=EOF){
		makePrimenumbers(a);
		result = countprime(a);
		printf("%d\n",result);
	}
  return 0;
}

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

int main()
{
	int count=0,n;
	bitset<1000001> prime;

	prime[0]=1;
	prime[1]=1;
	for(int i=2;i<=1000;i++)
		if(prime[i]==0)
			for(int j=i+1;j<=1000000;j++)
				if(j%i==0)
					prime[j]=1;
	
	while(cin>>n)
	{
		for(int i=0;i<=n;i++)
			if(prime[i]==0)
				count++;
		cout<<count<<endl;
	}
		
}

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

using namespace std;

bool isprime(int n)
{
	for (int i = 2; i <= sqrt(n); i++)
	{
		if (n % i == 0) return false;
	}

	return true;
}

int main()
{
	int N;

	int C = 0;

	cin >> N;

	for (int i = 2; i <= N; i++)
	{
		if (isprime(i) == true)
		{
			C += 1;
		}
	}

	cout << C << endl;

	return 0;
}

C++: #include <iostream>

using namespace std;

int main()
{
    int t[999999];

    return 0;
}

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

int main(void) {
	vector<int> v;
	v.push_back(2);
	v.push_back(3);
	int i, j;
	bool flag;
	for (i = 5; i < 999999; i++) {
		flag = true;
		for (j = 2; j <= sqrt(i); j++) {
			if (i % j == 0) {
				flag = false;
				break;
			}
		}
		if (flag) {
			v.push_back(i);
		}
	}
	int n;
	while (cin >> n) {
		i = distance(v.begin(), lower_bound(v.begin(), v.end(), n));
		if (v[i] == n)
			cout << i + 1 << endl;
		else 
			cout << i << endl;
	}

}

C++: #include<iostream>
#include<vector>
using namespace std;
int main(){
	int time;
	vector<int> v;
	v.push_back(2);
	v.push_back(3);
	while(cin>>time){
		int abcd=0;
		if(time>v[v.size()-1]){
			for(int abc=1+v[v.size()-1];abc<=time;abc+=2){
				for(int bcd=0;bcd<(int)v.size() ;bcd++){
					if(abc%v[bcd]==0){
						goto end;
					}
				}
				v.push_back(abc);
				end:;
			}
		}
		for(int abc=0;v[abc]<=time;abc++){
			abcd++;
		}
		cout<<abcd<<endl;
	}
	return 0;
}