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<stdio.h>
#include<iostream>
#include<string.h>
#include<vector>
#include<math.h>
#include<queue>
#include<algorithm>

using namespace std;

long store[999999];
//long storage[999999];
//int index=1;
bool IsPrime(long prime){
    if(prime==store[prime]){
        /*if(storage[index]!=0){
            storage[index]=storage[index]+1;
            index++;
        }*/
        return true;
    }
    //storage[index]=storage[index-1];
    //index++;
    bool ans=false;
    if(prime==2){
        store[prime]=prime;
        return true;
    }
    if(prime==3){
        store[prime]=prime;
        return true;
    }
    for(long i=2;i<=sqrt(prime);i++){
        if(prime%i==0) {
            return false;
        }
        else ans=true;
    }
    if(ans==true)   store[prime]=prime;
    return ans;
}

int main(){
    long n;

    //memset(storage,0,999999);
    while(scanf("%d",&n)==1){
        memset(store,-1,999999);
        long count=0;
        for(long i=n;i>0;i--){
            /*if(storage[i]!=0){
                count=count+storage[i];
                break;
            }*/
            if(IsPrime(i)==true)    count++;
        }
        printf("%ld\n",count);
    }

    return 0;
}

C++: #include <algorithm>
#include <cstring>
#include <stdio.h>
#include <vector>;
using namespace std;
const int maxn = 1e6+100;
bool prim[maxn];
vector <int> ve;

void get_prim() {
    prim[0] = prim[1] = true;
    for(int i=2;i<maxn;i++) {
        if(prim[i])
            continue;
        ve.push_back(i);
        for(int j=i*2;j<maxn;j+=i) {
            prim[j] = true;
        }
    }
}

int main() {
    int n;
    get_prim();
    while(scanf("%d",&n) != EOF) {
        int pos = lower_bound(ve.begin(),ve.end(),n) - ve.begin();
        if(ve[pos] > n)
            pos--;
        printf("%d\n",pos+1);
    }
    return 0;
}

C++: #include<iostream>
using namespace std;
int main(){
int n;
int max=1;
while(cin>>n){
for(int i=3;i<=n;i+=2){
for(int j=2;j<=i/2+1;j++){
if(i%j==0){max++;goto A;}
}
A:
;
cout<<max<<endl;
max=1;
}
}

C++: #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i,s,n) for(ll i=(s);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

ll eratosthenes(ll x){
    vbo isprime(x+1,true);
    isprime[0]=false;
    isprime[1]=false;
    ll p=0;
    for(ll i=2;i<=x;i++){
        if(isprime[i]){
            p++;
            for(ll j=2*i;j<=x;j+=i)isprime[j]=false;
        }
    }
    return p;
}

int main(){
    queue<int> q;
    int n;
    while(cin>>n)q.push(eratosthenes(n));
    while(q.size()){
        cout<<q.front()<<endl;
        q.pop();
    }
}

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

using namespace std;

int sosuu(int n);

int main(){
    int n=0;
    int num=0;
    int a[30]={0};
    int max=0;
    while(scanf("%d",&n)!=EOF){
        if(max<n){
            max=n;
        }
        a[num]=n;
        num++;
    }
    
    int b[max];
    for(int i=0; i<max; i++){
        b[i]=i;
    }
    b[1]=0;
    
    for(int i=2; i<sqrt(max); i++){
        for(int j=i+1; j<max; j++){
            if(j%i==0){
                b[j]=0;
            }
        }
    }
    for(int i=0; i<num; i++){
        int temp =a[i];
        a[i]=0;
        for(int j=0; j<=temp; j++){
            if(b[j]!=0){
                a[i]++;
            }
        }
        cout<<a[i]<<"\n";
    }
    
    
}
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<iostream>
#include<stdio.h>
#include<math.h>
#define INF 999999
using namespace std;

int main()
{
	int n;
	
	while (cin >> n)
	{
		int ans = 0,rootn;

		int a[INF] = {0};
		
		rootn = sqrt(n)+1;
	
		for (int i = 2; i <= rootn; i++)
		{
			if (a[i]==0)
			{
				for (int j = i+1; j <= INF; j++)
				{
					if (a[j] == 0 && j%i == 0)
					{
						a[j] = 1;
					}
				}
			}
		}
		cout << "a" << endl;
		for (int i = 2; i <= n; i++)
		{
			if (a[i]==0)
				++ans;
		}
		cout << ans << endl;
	}
			
	return 0;
}

C++: nclude <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <cstring>
#include <cctype>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <stdio.h>
#include <string.h>
#include <cstdlib>
#include <math.h>
#include <bitset>
#include <iterator>
#include <iomanip>
#include <sstream>
#include <numeric>
#define INF 2000000000
using namespace std;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
long long gcd(long long a,long long b){if(a%b==0){return b;}else return gcd(b,a%b);}
long long lcm(long long a,long long b){if(a==0){return b;} return a/gcd(a,b)*b;}
long long MOD; template<class T> void mod(T &n){MOD=n;}
#define sym cout<<"---------"<<endl;
#define ll long long
#define PL pair<long long, long long>
#define P pair<int,int>
#define mk make_pair
#define en endl
#define WHITE 1
#define BLACK 2
#define GRAY 1
#define RE return 0
#define int ll

bool prime[1000005]={true};

signed main(){
  int n;
  while(cin>>n){
    if(n==1){cout<<0<<en; continue;}
    for(int i=2; i<=n; i++) prime[i]=true;
    int ans=0;
    for(int i=2; i<=n; i++){
      if(prime[i]) {
        ans++;
        for(int j=2*i; j<=n; j+=i) prime[j]=false;
      }
    }
    cout<<ans<<en;
  }
}

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

int main()
{
     while(1){
     long int xx,sqrtx,q,count=1; 
     long double n;
	cin >> n;
	xx=n;
	sqrtx = sqrt(n);

	long int *ar = new long int [xx];
	long int *p = new long int [xx];
	for(long int i=2 ; i<=xx ; i++){    // 2〜xまでの整数
		ar[i]=i;
	}

	int i=2;
	do{
		if(ar[i]!=0){
			p[count]=i;
			count++;
		}
		for(int j=2*i ; j<=xx ; j+=i){
			ar[j]=0;
		}	
		i++;
	}while(i<sqrtx);

	cout << p[count-1] << endl;
        }
	return 0;
}

C++: #include <iostream>
#include <cmath>
using namespace std;
int main(){
	int n,k,kk;
	while(cin>>n){
		kk=0;
		for(int j=3;j<=n;j+=2){
			k=0;
			for(int i=3;i<=sqrt(j);i+=2){
				if(j%i==0)k++;
			}
			if(k==1)kk++;
		}
		if(n==1)cout<<"0"<<endl;
		else if(n==2)cout<<"1"<<endl;
		else cout<<kk+1<<endl;
	}
	return 0;
}

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

Int pn[1000002];

int main(){
int n, Count;
cin.tie(0);
while(scanf("%d",&n)!=EOF){
Count=0;
memset(pn,0,n);
pn[0]=pn[1]=1;
for(int i=2;i<=n;i++) if(!pn[i]) for(int j=1;i*j<=n;j++) pn[i*j]=1;
Count=count(pn,pn+n,0);
cout<<Count<<endl;
}
return 0;
}