Go: package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func main() {
	for sc.Scan() {
		a, _ := strconv.Atoi(sc.Text())
		fmt.Println(countPrime(a))
	}
}

func countPrime(a int) int {
	primes := make([]bool, a+1)
	n := 0
	for i := 2; i <= a; i++ {
		if primes[i] == false {
			n++
			for j := i * i; j <= a; j += i {
				primes[j] = true
			}
		}
	}
	return n
}

C++: #include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
using namespace std;

long int money = 100000;
int s = 100000;
int a[124],b[124];

int main(){
	int n;
	int tmp;
	cin>>n;
	//while(n!=0){
		money = 100000;
	for(int i=0;i<n;i++){
		money*=1.05;
		//if(i==n-1) cout << "\nbefore  \n" << money <<"\nafter"<<endl;
		if(i==24){
			tmp = money/100;
			//cout<<tmp<<endl;
		}
		tmp = money%1000;
		if(tmp!=0){
			money/=1000;
			money++;
			money*=1000;
			
		}
		b[i+1] = money;
		//if(i==n-1)	cout << money << endl;
	}
		cout<<b[n]<<endl;
		
		;
 
    
    //scanf("%d",&n);
 
 
    for(int i=0;i<n;i++){
        if(int(s*1.05)%1000==0){
            s=int(s*1.05);
        }else{
            s= int(s*1.05) + (1000- int(s*1.05) % 1000);
        }
    	a[i+1] = s;
    }
    //printf("%d\n",s);
	
		for(int i=0;i<n;i++)
			//cout<<i+1<<" a = "<<a[i+1]<<" b = "<<b[i+1]<<endl;
	//cout << money << endl;
		//cin >> n;
	//}
	return 0;
}

C++: #include<cstdio>
using namespace std;
const int N = 1000000;

int main(){

  int IsPrime[N];
  IsPrime[0] = 1;
  IsPrime[1] = 1;
  for(int i=2; i*i<=N;i++){
    if(IsPrime[i]==0){
      for(int j=2*i; j<=N; j+=i)
        IsPrime[j] = 1;
      }
  }
  int max;
  while(~scanf("%d",&max)){
    int count=0;
    for(int i=1; i<max+1; i++)
      if(IsPrime[i]==0) count++;
    printf("%d\n",count);
  }
}

C++: //↓template↓

#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
const long long INF = 1e18;
const long long MOD = 1e9 + 7;
const double pi = acos(-1);
const int SIZE = 1 << 17;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
long long fac[200005], finv[200005], inv[200005];
vector<long long>dij;
struct edge { long long to, cost; };
vector<vector<edge> >G;

long long mod_pow(long long a, long long b) {
	long long res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}

	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

//↑template↑

long long isp(long long n) {
	long longres;
	for (int i = 2; i <= sqrt(n); ++i) {
		if (n%i == 0) { ++res; }
	}
	return res;
}

int main() {
	long long n;
	while (cin >> n) { cout << isp(n) << endl; }
}

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

using namespace std;

bool p[3000000];
vector<int> prime;

void init(){
    memset(p,1,sizeof(p));
    p[0] = p[1] = false;
    for(int i = 2; i <= 1000000; i++){
        if(!p[i]) continue;
        for(long long j = 1LL*i*i; j <= 1000000; j += i)
            p[j] = false;
        prime.push_back(i);
    }
}

int CntPrime(int n){
    vector<int>::iterator it = lower_bound(prime.begin(), prime.end(), n);
    if(it == prime.end()) return prime.size();
    if( *it > n) it--;
    return (it - prime.begin()+1);
}

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

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

#define N 1000000L
bool num[N];

void furui(){
  long int i;
  int divide;
  int rt = 1000;
  for(i = 0L; i < N; i++){
    num[i] = true;
  }
  num[0] = false;
  num[1] = false;
  for(divide = 2; divide < rt; divide++){
    if(num[divide] == false) continue;
    for( i = divide; i < N; i+= divide){
      num[i] = false;
    }
    num[divide] = true;
  }
}

int main(void){
  int c, i, j;
  long int k, n, count;
  char buf[7];

  furui();

  for(j = 0; j < 30; j++){
    for(i = 0; ;i++){
      c = getchar();
      if(c == EOF || c == '\n'){
        buf[i] = '\0';
        break;
      }
      buf[i] = c;
    }
    n = atol(buf);
    count = 0L;
    for(k = 1L; k <= n; k++){
      if(num[k] == 1) count++;
    }
    std::cout << count << std::endl;
    if(c == EOF) break;
  }
  return 0;
}

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

int list[1000000] = {};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int n;
	while(cin >> n){
	
	if(list[n] != 0){
		cout << list[n] << endl;
		continue;
	}
		
	int cnt = 0;
	for(int i = 2; i <= n; ++i){
		bool check = true;
		for(int j = 2; i >= j * j; ++j){
			if(i % j == 0){
				check = false;
				break;
			}
		}
		if(check)
			cnt++;
		
		if(list[i] == 0){
			list[i] += list[i - 1] + check;
		}
	}
	
	cout << cnt << endl;
	
	}
	
	return 0;
}

C++: #include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
using namespace std;

bool isPrime(int n){
    if(n < 2) return false;
    if(n == 2) return true;
    if(n%2 == 0) return false;

    for(int i=3; i*i<=n; i++){
        if (n%i == 0) return false;
    }
    return true;
}

int main(){
    int n, cnt = 0, s[1000000]={0};
    REP(i, 1000000){
        if (isPrime(i)) s[i]++;
    }
    while(cin>>n){
        for(int i=0; i <= n; i++){
            if (s[i] == 1) cnt++;
        }
        cout << cnt << endl;
        cnt = 0;
    }
}

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

int keta(int x){
	int i=0;
	while (x/pow(10,i)>=1){
		i++;
	}
	if (x==0){
		return 1;
	}
	else
	return i;
	}


int main(){
int n;
int count=30;
while (true){
	cin>>n;
	if (count==0){
		break;
	}
	int yakusu=0;
	for (int i=2;i<=n;i++){
		bool flag=true;
		for (int j=2;j<i-1;j++){
			if(i%j==0){
				flag=false;
			}
		}
		if (flag){
		yakusu++;
		}

	}
cout<<yakusu<<endl;
count--;
}
return 0;
}

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

int main() {
int b[1000];
for (int k=0;k<1001;k++){
	b[k]=0;
}
for (int p=2;p<1001;p++){
int i,a=0 ;
	i=2;
	while(i<p){
		if(p%i==0){
			break;
	}i=i+1;
	}
	if (i==p){
		a=1;
	}
	b[p]=a;
}
int c[1000];
for (int l=0;l<1001;l++){
	c[l+1]=c[l]+b[l+1];
}
int r;
while(cin>>r){
	cout<<c[r]<<endl;
}
	return 0;
}

C++: #include<iostream>
int main()
{
	int result[30];
	int num;
	for(int i = 0;; i++)
	{
		int n;
		std::cin >> n;
		if(std::cin.eof())
		{
			num = i;
			break;
		}
		result[i] = 0;
		bool*is_prime = new bool[n - 1];
		for(int j = 0; j < n - 1; j++)
		{
			is_prime[j] = true;
		}
		for(int j = 0; j < n - 1; j++)
		{
			if(is_prime[j])
			{
				for(int k = 2;; k++)
				{
					if((j + 2)*k - 2 >= n - 1)
					{
						break;
					}
					is_prime[(j + 2)*k - 2] = false;
				}
			}
		}
		for(int j = 0; j < n - 1; j++)
		{
			if(is_prime[j])
			{
				result[i]++;
			}
		}
	}
	for(int i = 0; i < num; i++)
	{
		std::cout << result[i] << std::endl;
	}
	return 0;
}

C++: #include <cstdio>
#include <iostream>
using namespace std;
int prime[1000005];
bool is_prime[1000005];
int seve(int n)
{
    int p=0;
    for(int i=0;i<=n;i++)
        is_prime[i]=true;
    is_prime[0]=is_prime[1]=false;
    for(int i=2;i<=n;i++)
    {
        if(is_prime[i])
        {
            prime[p++]=i;
            for(int j=2*i;j<=n;j+=i)
                is_prime[j]=false;
        }
    }
    return p;
}
int main(void)
{
    int n;
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",seve(n));
    }
    return 0;
}

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

using namespace std;

int main()
{ 
	int n;
	while (cin >> n)
	{
		vector<bool> a(n + 1, true);
		int cnt = n - 1;

		// Sieve of Eratosthenes
		for (int i = 2; i*i < n; ++i)
			if (a[i])
				for (int j = 0; i * (j + 2) <= n; ++j)
					if (a[i * (j + 2)]) a[i * (j + 2)] = false, cnt--;

		cout << cnt << endl;
	}

	return 0;
}