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>
using namespace std;
const int MAX_V = 1000000; // 100????????§?´???°??¨?????????
int prime[MAX_V+1]; // 1????´???°???0????´???°??§?????? 
int pcount[MAX_V+1];
int main() {
    int i, k, v,a,sum=0;
    for(i = 2; i <= MAX_V; i++) {
        prime[i] = 1; // 2??\????´???°??¨??????
    } 
    for(i = 2; i*i <= MAX_V; i++) {
        if(prime[i]) {
            for(k = 2 * i; k <= MAX_V; k += i) {
                prime[k] = 0; // ?´???°2?????\????????°?´???°??§?????? 
            }
            
        } 
        
    }
    pcount[0]=0;
    pcount[1]=0;
    for(i=2;i<MAX_V;i++){
        if(prime[i]){
            sum++;
        }
        pcount[i]=sum;
    }
    while(1) {
        scanf("%d",&a);
        printf("%d\n",pcount[a]);
    } 

    return 0; 
    
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int whether(int num);
int count(int num);

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

int whether(int num){
    int s=sqrt(num);
    int i;
    
    for(i=3; i<=s; i+=2){
        if(num%i==0){ return 0; }
    }
    
    return 1;
}

int count(int num){
    int a=1;
    if(num<2){ return 0; }
    if(num==2){ return 1; }
    for(int i=3; i<=num; i+=2){
        if(whether(i)){ a+=1; }
    }
    
    return a;
}

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

int main()
{
	int n;
	int max;
	while(cin>>n)
	{
		max = sqrt(1.0*n);
		vector<bool> prime(n+1, true);
		prime[0]=false;
		prime[1]=false;
		for(int i=2; i<=max; ++i)
		{
			if(prime[i])
			{
				for(int j=i*2; j<=prime.size()-1; j+=i)
				{
					prime[j]=false;
				}
			}
		}
		cout << accumulate(prime.begin(), prime.end(), 0) << '\n';
	}
}

C++: #ifndef VS
#include<iostream>
#include<vector>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<assert.h>
#include<math.h>
#endif

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {
	cww() { CIN_ONLY{ ios::sync_with_stdio(false); cin.tie(0); } }
}star;
#define DEBUG if(0)
#endif

#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r) { bool a = l>r; if (a)l = r; return a; }
template <typename T>inline bool chmax(T &l, T r) { bool a = l<r; if (a)l = r; return a; }
namespace prime {
	const int size = 1123456;
	int p[size];
	struct prime {
		prime(){
			REP(i, size)p[i] = 1;
			p[0] = p[1] = 0;
			REP(i, size)if (p[i]) {
				for (int j = i + i; j < size; j += i)p[j] = 0;
			}
			FOR(i, 1, size) {
				p[i] += p[i - 1];
			}
		}
	}prime_init;
}
int main() {
	int n;
	while (cin >> n) {
		cout << prime::p[n] << endl;
	}
}

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

long long gcd(long long a, long long b)
{
    return b?gcd(b,a%b):a;
}
long long m,n;
int main()
{
    while(~scanf("%lld%lld",&m,&n))
    {
        long long temp = gcd(m,n);
        printf("%lld %lld\n",temp,m/temp*n);
    }
    return 0;
}

C++: #include <iostream>
int main(int argc, const char * argv[])
{

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        int count = 0;
        
        for(int i=2;i<n;i++)
        {
            bool flag = true;
            for(int j=2;j<i/j+1;j++)
            {
                if(i%j==0)
                {
                    flag=false;
                    break;
                }
            }
            if(flag)
            {
                count++;
            }
        }
        
        std::cout << count <<"\n";
        
    }
    
    return 0;
}

C++: #include <iostream>

using namespace std;

void solve(int n) {
	int prime[n];
	int j=0;
	for (int i=2; i<=n; i++) {
		prime[j] = i;
		j++;
	}
	int p;
	for (int i=0; i<n; i++) {
		p = prime[i];
		if (p == -1) continue;
		for (int k=i+1; k<n; k++) {
			if (prime[k]%p == 0)
				prime[k] = -1;
		}
	}
	int count = 0;
	for (int i=0; i<n; i++)
		if (prime[i] != -1) count++;
	cout << count << endl;
}

int main() {
	int n;
	while (cin >> n) {
		if (n<=1) cout << 0 << endl;
		solve(n);
	}
	return 0;
}

C++: #include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
int main(){
	int n,cnt=0,ans,sosu[1000003]={0};
	
	for(int i=2;i<1000002;i++){
		bool flag=true;
		for(int j=2;j<=sqrt(i);j++){
			if(i%j==0)flag=false;
		}
		/*if(flag){
		cnt++;
		sosu[i]=cnt;
		}*/
		sosu[i]=(flag)? cnt++ : cnt;		
	}
	//for(int i=0;i<30;i++)cout<<sosu[i]<<" ";
	while(cin>>n){
	cout<<sosu[n]<<endl;
	}
    return 0;
}

C++: #include <bits/stdc++.h>
#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = (a); i < (b); ++i)
#define pb push_back
typedef long long ll;
typedef long double la;
using namespace std;

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;
}

int gcd(int a, int b)
{
    if(b==0)
        return a;

    return gcd(b, a%b);
}

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(1){
        int n;
        cin >> n;
        if(cin.eof()){
            break;
        }
        cout << n_prime[n] << endl;
    }
}

C++: ///BISMILLAHIR RAHMANIR RAHMIM
#include <bits/stdc++.h>
using namespace std;
#define MAX 1000002
int pri[MAX+2];
int cnt[MAX+2];
void sieve(int n)
{
    pri[1]=1;
    for (int i=2;i<=n;i++)
    {
        if(pri[i]==0)
        {
            for (int j=i+i;j<=n;j+=i)
            {
                pri[j]=1;
            }
        }
    }
    int tot = 0;
    for(int i = 1;i<=n;i++)
    {
        if(pri[i]==0)
            tot++;
        cnt[i] = tot;
    }
}
int main ()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    sieve(MAX);
    int n;
    while(cin>>n)
    {
        cout << cnt[n] << "\n";
    }
    return 0;
}

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

bool is_sosu(int x){
	int i;
	if(x<2) return false;
	for(i=2;i<=sqrt((double)x);i++){
		if(x%i==0) return false;
	}
	return true;
}

int main()
{
	long int n,x;
	int ans;
	while(cin>>n){
		ans=0;
		for(x=1;x<=n;x++){
			if(is_sosu(x)==true) ans++;
		}
		cout<<ans<<endl;
	}
}