Go: package main

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

var scanner = bufio.NewScanner(os.Stdin)

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

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

func main() {
	for scanner.Scan() {
		n := nextInt()
		cnt := 0
		for i := 2; i <= n; i++ {
			if isPrime(i) {
				cnt++
			}
		}
		fmt.Println(cnt)
	}
}

C++: #include <iostream>
#include <memory.h>
using namespace std;
int main()
{
	bool prime[1000010];
	memset(prime,1,1000010);
	prime[0]=prime[1]=0;
	int i,j,n,sum;
	for (i=2;i<1000000;i++)
	{
		if (prime[i])
		{
			for (j=2;i*j<1000000;j++)
			{
				prime[i*j]=false;
			}
		}
	}
	while(cin>>n)
	{
		sum=0;
		for(i=2;i<=n;i++)
		{
			sum+=prime[i];
		}
		cout<<sum<<endl;

	}	
	return 0;
}

C++: #include<iostream>

using namespace std;

int main(void){
	
	long int n,f,k,i;
	int count;
	bool chk;
	while(scanf("%d",&n)!=EOF){
		count=0;
		for(i=2;i<=n;i++){
		
			chk=0;
			f=i/2;
			k=2;
		
			while(f>=k){
				if((i%k)==0){
					chk=true;
					break;
				}
				k++;
			}
		
			if(chk==false){
				count++;
			}
		}
		cout<<count<<endl;
	}
}

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

int main(){
	int yaku = 0,n,hoge = 0;
	while(cin >> n){
		hoge = 0;
		for(int i = 1;i <= n;i++){
			yaku = 0;
			for(int j = 1;j <= i;j++){
				if(i % j == 0) yaku++;
			}
			if ( yaku == 2)	hoge ++;
		}
		cout <<  hoge << endl;

	}

}

C++: #include<iostream>
#include<algorithm>
using namespace std;
int arr[1000000]={0};
bool isPrime(int n){ 
    if(n<2)
        return false;
    for(int i=2; i*i<=n; i++){
        if(n%i==0)
            return false;
    }   
    return true;
}
void arra(int n, int m){ 
    int c=0;
    if(n>m){
        int memo=m;
        m=n;
        n=memo;
    }   
    for(int i=n+1; i<=m; i++){
        if(isPrime(i)){
            c++;
            //arr[i]=arr[n]+c;
        }   
        arr[i]=arr[n]+c;
    }   
    //arr[m]=arr[n]+c;
}
int main(){
    int n, m=0;
    while(cin>>n){
        if(arr[n]==0){
            arra(n, m); 
        }   
        cout<<arr[n]<<endl;
        m=max(n, m); 
    }   
    return 0;
}

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

bool isprime(int number, std::vector<int> const& primeset)
{
	int maxprime = static_cast<int>(std::sqrt(static_cast<float>(number)));

	typedef std::vector<int>::const_iterator Iter;
	Iter primesetlimit = std::upper_bound(primeset.begin(), primeset.end(), maxprime);
	for (Iter p = primeset.begin(); p != primesetlimit; ++p) {
		if (number % *p == 0) {
			return false;
		}
	}
	return true;
}

int resolve(int number)
{
	if (number < 2) {
		return 0;
	}
	if (number == 2) {
		return 1;
	}
	std::vector<int> primesetExceptTwo;
	for (int i = 3; i <= number; i += 2) {
		if (isprime(i, primesetExceptTwo)) {
			primesetExceptTwo.push_back(i);
		}
	}
	return static_cast<int>(primesetExceptTwo.size()) + 1;
}

int main()
{
	int input;
	while (std::cin >> input) {
		std::cout << resolve(input) << std::endl;
	}

	return 0;
}

C++: #define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#include <bits/stdc++.h>
using namespace std;

int main(){
  int a[1000010];
  rep(i,1000010) a[i]=1;
  
  rep(i,1000000){
    if(i<2){
      a[i]=0;
      continue;
    }
    if(i==2){
      a[i]=1;
      continue;
    }
    else if(i%2==0){
      a[i]=0;
      continue;
    }
    
    for(int j=3;j*j<=i;j+=2){
      if(i%j==0){
        a[i]=0;
        continue;
      }
    }
  }
  
  int dp[1000010];
  dp[0]=0;
  for(int i=1;i<1000009;i++){
    if(a[i]) dp[i]=dp[i-1]+1;
    else dp[i]=dp[i-1];
  }
  
  int n;
  while(cin>>n){
    cout<<dp[n]<<endl;
  }
  
  return 0;
}

C++: #define _USE_MATH_DEFINES
#include <iostream> 
#include <math.h>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std; 
int main(){
	int N;
	while(cin >> N)
	double p = log2(N);
	while (cin >> N){
		int sum =0;
		cout << N*p << endl;
	}
	return 0;
}

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

int main()
{
    bool notPrime[1000000]={false};
    notPrime[0]=notPrime[1]=true;
    for (unsigned i=3; i<1000000; i+=2) {
        if (!notPrime[i]) {
            for (unsigned j=2; i*j<1000000; j++) {
                notPrime[i*j]=true;
            }
        }
    }
    for (unsigned n, count; cin >> n; cout << count << endl) {
        count=0;
        if (n>=2) {
            count++;
            for (unsigned i=3; i<=n; i+=2) {
                if (!notPrime[i]) {
                    count++;
                }
            }
        }
    }
    return 0;
}

C++: #include <stdio.h>
#include <math.h>
int sosuu(int x){
    int n,m,sosuu;
    sosuu=x-2;
    for(n=2;n<x;n++){//nは素数を調べる。入力された数字まで１からスライドしていく。
        for(m=2;m<n;m++){//mはnが素数かどうか調べる。素数かどうかをnより小さい数字で数えていく。2からなのは2から素数だから。1はふくめない。
            if(n%m==0){//素数じゃなかったら、つまり割り切れてしまったら。
                sosuu--;
            }
           
            if(n%m==0) break;
        }
    }
    if(x==1||x==0) sosuu=0;
    return sosuu;
}

int main ( void ) {
    int s,result;
    while(scanf("%d",&s)!=EOF){
        result = sosuu(s);
        printf("%d\n",result);
    }
    return 0;
}

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

int main(){
    long maxy = (long)sqrt(1000000);
    int prime[maxy];
    //ツエツδ可トツスツテツネツスツづ個づ督づゥツつ「
    
    for(int i = 0; i < maxy; i++){
        prime[i] = 1;
    }
    prime[0] = prime[1] = 0;
    for(int i = 2; i <= (int)maxy; i++){
        if(prime[i] == 1){
            for(int j=i*2; j <= (int)maxy; j+=i){
                prime[j] = 0;
            }        
        }
    }
    int n;
    while(cin >> n){
        int ans = 0;
        for(int i=0; (i <= maxy && i <= n); i++){
            if(prime[i] == 1){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        if(std::cin.eof())break;
        
        int count = 0;
        std:
        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;#include <iostream>
int main(int argc, const char * argv[])
{

    // insert code here...
    
    while(true)
    {
        int n;
        std::cin >> n;
        if(std::cin.eof())break;
        
        int count = 0;
        std:
        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;
}


                }
            }
            if(flag)
            {
                count++;
            }
        }
        
        std::cout << count <<"\n";
        
    }
    
    return 0;
}