Go: package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	var primeCount int
	for sc.Scan() {
		input := nextInt()
		for i := 0; i <= input; i++ {
			if IsPrime(i) {
				primeCount++
			}
		}
		fmt.Printf("%d\n", primeCount)
		primeCount = 0
	}
}

func IsPrime(num int) bool {
	switch {
	case num == 2 || num == 5:
		return true
	case num < 2 || num%2 == 0 || num%5 == 0:
		return false
	}
	sqrt := math.Sqrt(float64(num))
	for i := 3; i <= int(sqrt); i += 2 {
		if num%i == 0 {
			return false
		}
	}
	return true
}

func next() string {
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

C++: #include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;

/*---------------------------------------------------*/

int n;
int weight[30],max_weight[30];

bool DFS(int now,int cnt,bool used[]){
  //cout<<"DEBUG: "<<now<<" "<<cnt<<endl;
  bool ok=false;
  if(cnt==n)return true;
  rep(i,n){
    if(!used[i]&&now+weight[i]<=max_weight[i]){
      used[i]=true;
      ok=DFS(now+weight[i],cnt+1,used);
      if(ok)return true;
      used[i]=false;
    }
  }
  return false;
}

int main(){
  bool used[26];
  while(cin>>n){
    if(n==0)break;
    rep(i,n)cin>>weight[i]>>max_weight[i];
    bool ok=false;
    rep(i,n){
      used[i]=true;
      if(DFS(weight[i],1,used))ok=true;
      used[i]=false;
    }
    if(ok)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
}

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

int pn[1000002];

int solve (int n) {
  int Count = 0;
  memset(pn, 0, n);
  pn[0] = pn[1] = 1;
  for (int i = 2; i <= n; i++) if (!pn[i]) for (int j = 2; i * j <= n; j++) pn[i * j] = 1;
  Count = count(pn, pn+n+1, 0);
  return Count;
}
	

int main (void) {
  int n;
  cin.tie(0);
  while (scanf("%d", &n) != EOF) {
    cout << solve(n) << endl;
  }
  return 0;
}

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

int main()
{
	
	long int k,p[100000];
	float n;
	p[0]=2;
	while(cin>>n){
		if(n<0){
			break;
		}
	k=0;
	int r=(int)sqrt(n);
	for(int i=3;i<=r;i++){
		for(int j=0;j<k+1;j++){
			if(i%p[j]==0){
				break;
			}else if(j==k){
				k++;
				p[k]=i;
			}
		}
	}
	int r_k=k;
	for(;r<n;r++){
		for(int i=0;i<=r_k;i++){
			if(r%p[i]==0){
				break;
			}else if(i==r_k){
				k++;
			}
		}
	}
	if(k!=0&&k!=1){
		k+=1;
	cout<<k<<endl;
	}else{
		cout<<k<<endl;
	}
}
}

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

int Sum_of_Prime(int n);
bool isPrime(int n);
int main()
{
	int N;
	while(cin>>N)
	{
		cout<<Sum_of_Prime(N)<<endl;
	}
	return 0;
} 
int Sum_of_Prime(int n)
{
	int p=1;
	if(n<2)
		return 0;
	for(int j=3;j<=n;j+=2)
	{
		if(isPrime(j))
			p++;
	}
	return p;
}

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

C++: #include<iostream>
using namespace std;
int main()
{
	int n,S;
while(cin>>n)
{
	S=0;
	if(n==1)
	{
		cout<<0<<endl;
	}
	if(n>=2)
	{
		S++;
	}
	for(int i=2;i<=n;i++)
	{
		for(int j=i-1;j>1;j--)
		{
			if(i%j==0)
			{
				break;
			}
			if(j==2)
		{
			S++;
		}
		}	
			
	}
	cout<<S<<endl;
}
return 0;
}

C++: #include <stdio.h>

const int MAX_V = 1000000;

int main() {
	int i, k, v;
	int prime[MAX_V + 1];
	int sum[MAX_V + 2];
	for (i = 2; i <= MAX_V; i++) {
		prime[i] = 1;
	}
	for (i = 2; i * i <= MAX_V; i++) {
		if (prime[i]) {
			for (k = 2 * i; k <= MAX_V; k += i) {
				prime[k] = 0;
			}
		}
	}
	sum[1] = 0;
	sum[2] = 0;
	for (i = 2; i <= MAX_V; i++) {
		sum[i + 1] = sum[i] + prime[i];
	}
	while (scanf("%d", &v) != EOF) {
		printf("%d\n", sum[v + 1]);
	}
	return 0;
}

C++: #include <iostream>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

const int N = 100000;

int main(void)
{
    bool a[N];
    int prime[N], n;
    rep(i,N+1)
    {
        a[i] = true;
    }
    a[0] = a[1] = false;
    for(int i=2;i*i<=N;i++)
    {
        if(a[i])
        {
            prime[i] = prime[i-1] + 1;
            for(int j=i*i;j<N;j+=i)
                a[j] = false;
        }
        else
            prime[i] = prime[i-1];
    }

    while(cin >> n)
        cout << prime[n] << endl;
    
    return 0;
}

C++: #include<iostream>
#include<cmath>
using namespace std;
int main() {
	int n;
	while (cin >> n){
		int sum = 0;
		if (n >= 2)sum++;
		for (int i = 3; i <= n; i += 2) {
			for (int j = 3; j <= sqrt(i); j += 2) {
				if (i%j == 0)goto x;
			}
			sum++;
		x:;
		}
		cout << sum << endl;
	}
	return 0;
}

C++: #coding:utf-8
import time
import math
import numpy as np

def flatten(L):
    if isinstance(L, list):
        if L == []:
            return []
        else:
            return flatten(L[0]) + flatten(L[1:])
    else:
        return [L]

def Eratos(data):

    p_list = [] # ????????????
    tmp = []
    num = int(math.sqrt(len(data)))+1
    for i in data:
        i=data[0]
        if i>num:
            break
        else:
            p_list.append(i)
            for j in data:
                if j%i == 0:
                    data.remove(j)
        
    p_list.append(data)
    return p_list

x = int(input())

r_list = list(range(2,(x+1)))
ans = []
ans = Eratos(r_list)

print("prime numbers is ")

print(len(flatten(ans)))

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

bool prime[MAX];

int countPrime(int n){
	if(n < 2) return 0;
	if(n == 2) return 1;

	int ret = 0;

	for(int i = 0; i < MAX; i++){
		prime[i] = true;
	}

	for(int i = 2; i * i <= n; i++){
		if(prime[i]){
			for(int j = i*i; j <= n; j += i){
				prime[j] = false;
			}
		}
	}
	for(int i = 2; i <= n; i++){
		if(prime[i]) ret++;
	}
	return ret;
}

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

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

using namespace std;

int prime(int n);

int main(){
  vector<int> inp;
  int num,pri;					
  int i=0;

  while(cin>>num){
    if(num <= 1)inp.push_back(0);
    else{
      pri = prime(num);
      inp.push_back(pri);
    }
    i++;
  }
  int j = 0;
  while(j < i){
    cout<<inp[j]<<endl;
    j++;
  }
}

int prime(int num){
  int count=0;
  bool judge=0;
  for(int i = 2; i <= num; i++){
    judge =1;
    for(int j= 2; j < i; j++){
      if(i%j == 0)judge =0;
    }
    if(judge==1)count = count +1; 
  }
  return count;
}

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

int count_prime_number(int n){
	if(n < 2){
		return 0;
	}
	int count = 1;	//2??????
	for(int i = 3; i <= n; i += 2){
		int k = 0;
		for(int j = 3; j <= sqrt(i); j += 2){
			if(i % j == 0){
				k=1;
				break;
			}
		}
		if(k==0){
			count++;
		}
	}
	return count;
}

int main(){
	vector<int> results;
	int in_num;
	while(cin >> in_num){
		results.push_back(count_prime_number(in_num));
	}
	for(auto result : results){
		cout << result << endl;
	}
	return 0;
}