Go: package main

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

func main() {
	scanner := bufio.NewScanner(os.Stdin)

	for scanner.Scan() {
		num, _ := strconv.Atoi(scanner.Text())
		flag := false
		count := 0

		for i := 2; i <= num; i++ { //1を除く入力値以下の数字
			for j := 2; j < i-1; j++ {
				if i%j == 0 && j != 1 {
					flag = true
					//fmt.Println(i, "/", j)
					break
				}
			}
			if !flag {
				count++
			} else {
				flag = false
			}
		}
		fmt.Println(count)
	}
}

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

int main()
{
	int prime[1000000];
	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 count = 0;
	for (int i = 0; i < 1000000; i++) {
		if (is_prime[i])
			count++;
		prime[i] = count;
	}
	int n;
	while (cin >> n) {
		cout << prime[n] << endl;
	}
	return 0;
}

C++: #include<iostream>
#include<math.h>
#define MAX (1000000)
using namespace std;

int N;
int array[MAX];
int count = 0;
int main(){
	cin >> N;
	
	for(int i=0; i < N; i++){
		array[i]=1;
	}
	
	for(int i=2; i < sqrt(N); i++){
		for(int j=1; i*j < N; j++){
			array[i*j] = 0; 
		}
	}
	
	for(int i=0; i < N; i++){
		if(array[i] == 1){
			count++;
		}
	}
	cout << count << endl;
	
	return 0;
}

C++: #include<iostream>

using namespace std;

int n;
int prime[1000000];
int checked[1000000];
int primesum[1000000];
int result[30];
int datasets;

int main()
{
	prime[0] = 0;
	prime[1] = 0;
	prime[2] = 1;
	primesum[0] = 0;
	primesum[1] = 0;
	primesum[2] = 1;
	
	for(int a = 3;a<1000000;a++)
	{
		if(checked[a] == 0)
		{
			prime[a] = 1;
			checked[a] = 1;
			for(int b = 2;b<a;b++)
			{
				if(a%b==0)
				{
					prime[a] = 0;
					break;
				}
			}
			if(prime[a] == 1)
			{
				for(int c = 2*a ;c<1000000;c+=a)
				{
					checked[c] = 1;
				}
			}
		}
		primesum[a] = primesum[a-1]+prime[a];
	}
	
	while(cin >> n)
	{
		cout << primesum[n] << endl;
	}

	return 0;
}

C++: #include<iostream>

using namespace std;

int main(){
	int n;
	int p[1000000] = { 1 };
	int ans[1000000] = { 0 };
	p[0] = 0;
	p[1] = 0;

	for (int i = 2; i*i < 1000000; i++){
		if (p[i]){
			for (int j = 2 * i; j < 1000000; j += i){
				p[j] = 0;
			}
		}
	}

	for (int i = 0; i < 1000000; i++){
		ans[i] += p[i];
	}

	while (cin >> n)
		cout << ans[n] << endl;

}

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)))