Go: package main

import (
	"fmt"
	"math"
)

func main() {
	var primeCount, input int
	for {
		fmt.Scanf("%d", &input)
		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:
		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 <iostream>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#define MAX_N 100000

void q9() {
	bool IsPrime[MAX_N];
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = false;
	IsPrime[1] = false;
	for (int i = 0; i < sqrt(MAX_N); i++) {
		if (!IsPrime[i]) continue;
		for (int j = i * 2; j < MAX_N; j += i) {
			IsPrime[j] = false;
		}
	}

	int NofP[MAX_N];
	NofP[0] = 0;
	for (int i = 1; i < MAX_N; i++) {
		NofP[i] = NofP[i - 1] + IsPrime[i];
	}

	int n;
	for (; cin >> n;) {
		cout << NofP[n] << endl;
	}
}

int main() {
	q9();
	return 0;
}

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

int main(){
        int prime[999999];
        bool is_prime[1000000];
        int p =0;
        int n ;
        int i;
        while(cin >> n){
        for(i=0;i<=n;i++) is_prime[i] = true;
        is_prime[0] = is_prime[1] = false;
        for(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;
                }
        }
        cout << p << endl;
        p = 0;
        }
return 0;
}

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

int main(){
int n;
vector<int> a;
  while(cin < n){
  a.push_back(n);
  }
for(int i=0;i<a.size();i++){
  int k = 0;
  for(int j=2;j<a[i];j++){
    if(a[i]%j == 0 ) k++;
	}
  cout << k ;
 }
}

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

const int N = 1000000;
int data[1000000];
int n;

void Eratosthenes(){
  for(int i=0; i<N; i++){
    data[i] = 1;
  }
  for(int i=2; i<sqrt(N); i++){
    if(data[i]){
      for(int j=0; i*(j+2)<N; j++){
	data[i *(j + 2)] = 0;
      }
    }
  }
}

int main()
{
  int cnt = 0;
  Eratosthenes();
  while( cin >> n ) {
    cnt = 0;
    for(int i=2; i<=n; i++) {
      if( data[i] ) cnt++;
    }

    cout << cnt << endl;
  }
}

C++: #include<iostream>

int n;
int p;
int prime[1000000];
bool isprime[1000000];

void sieve()
{
	p = 0;
	isprime[0] = isprime[1] = false;
	for( int i = 2; i <= n; i++ ) isprime[i] = true;
	
	for( int i = 2; i <= n; i++ ){
		if( isprime[i] ){
			isprime[i] = false;
			prime[p++] = i;
			for( int j = i * 2; j <= n; j += i ) isprime[j] = false;
		}
	}

 	return;
}

int main()
{
	while( std::cin >> n ){	
		sieve();
		std::cout << p << std::endl;
	}

 	return 0;
}

C++: #include <iostream>
#include <vector>
#include <algorithm>
#define pb(a) push_back(a) 
#define rep(i,a,n) for(int i=a; i<n; i++)
using namespace std;
 
int main() {
    int n = 1000000;
    vector<int> v;
    v.pb(2);
    for(int i=3;i<=n;i+=2) {
        bool add = true;
        rep(j,0,v.size()) {
            if(v[j] * v[j] > i) break;
            if(i % v[j] == 0) {
                add = false; 
                break;
            }
        }
        if(add) v.pb(i);
    }

    int m;
    while(cin >> m) {
        cout << upper_bound(v.begin(), v.end(), m) - v.begin() << endl;
    }
    return 0;
}

C++: /*http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0009&lang=jp*/

#include <iostream>

using namespace std;

int main()
{
    int n;

    while (cin>>n){
        int count=0;

        if(1<n){
            count++;
        }
        if(n%2==0){
            n--;
        }
        while (1 < n){
            int prime_flag=1;
            for (int j = 2; prime_flag && j < n; j++) {
                if(n % j == 0){
                    prime_flag=0;
                }
                if(2 < j){
                    j++;
                }
            }
            count+=prime_flag;
            n-=2;
        }
        cout<<count<<endl;
    }
    return 0;
}

C++: #include<iostream>
#include<string>
#include <stdio.h>
#include <math.h>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int count=0;
		for(int i=5;i<=n;i+=6){
			int j=5;
			while(true){
				if(i%j==0)
					break;
				if(j>(int)sqrt((double)i)){
					count++;
					break;
				}
				j+=2;
			}
		}
		for(int i=7;i<=n;i+=6){
			int j=5;
			while(true){
				if(i%j==0)
					break;
				if(j>(int)sqrt((double)i)){
					count++;
					break;
				}
				j+=2;
			}
		}
		cout<<count+1<<endl;
	}
	return 0;
}

C++: import java.util.Scanner;
import java.io.*;
class Main{
    public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    int ans,n;
    while(sc.hasNext()){
    	n=sc.nextInt();
    	ans=0;
    	if(n==1)ans=-1;
    	for(int i=1;i<=n;i+=2){
    		int flag=0;
    		for(int j=3;j<=Math.sqrt(i);j+=2){
    			if(i%j==0){
    				flag=1;break;
    			}
    		}
    		if(flag==0)ans++;
    	}
    	System.out.println(ans);
    }
    }
}

C++: #include <stdio.h>

int IsPrime(int n);

int main(void){
    int n, cnt, minID, min=1;
    int max[30], sol[30], listID=0;
	
    while (scanf("%d", &n) && n!=EOF){
        cnt=0;
        min = 1;
        minID = 0;
		printf("check %d ->", n);
        for (int i=0; i<listID; i++){
            if (max[i] < n && min <max[i]){
                min = max[i];
				cnt = sol[i];
            }
        }
		printf("check  %d - %d (cur sols = %d)\n", min+1, n, cnt);
        for (int i=min+1; i<=n; i++){
            if (IsPrime(i)) cnt++;
        }
        max[listID] = n;
        sol[listID] = cnt;
        listID++;
        printf("%d\n", cnt);
    }
    return 0;
}

int IsPrime(int n){
    int i;
    for (i=2; i*i<=n; i++){
        if (n%i==0) return 0;
    }
    return 1;
}

C++: #include<stdio.h>
#include<math.h>
int isprime(int x){
	int i=3;
	while( i <= sqrt(x) ){
		if(x%i==0)return 0;
		i = i + 2;
	}
	return 1;
}
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		int c=1;
		for(int i=3;i<=n;i+=2){
			if(isprime(i))c++;

		}
		printf("%d\n",c);
	}
	return 0;
}

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

int main(){

	const int N_MAX=100;
	int i,j,n[32],ni,soi,max;
	int so[N_MAX],count[N_MAX];
	
	for(i=0;i<N_MAX;i++)
		count[i]=so[i]=0;
	ni=0;
	max=0;
	while(cin>>n[ni])
		if(n[ni++]>max)
			max=n[ni-1];
	int sq_max = (int)sqrt(max);
	so[0]=so[1]=1;
	for(soi=0,i=2;i<=sq_max;i++){
		if(so[i]>0)continue;
		for(j=i*2;j<=max;j+=i)
			so[j]=1;
	}
	for(i=2;i<=max;i++){
		count[i] = count[i-1]+1-so[i];
	}
	for(i=0;i<ni;i++)
		cout << count[n[i]] << endl;

	return 0;
}

C++: #define _CRT_SECURE_NO_WARNINGS
#define M_PI 3.14159265358979
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include<iomanip>
#include<vector>
#include<cmath>
#include <algorithm>

using namespace std;

int yakusuu(int i){
	int counter=0;
	for (int j = 1; j <= i; j++){
		if (i%j == 0) counter++;
	}
	return counter;
}


int main()
{
	int n;
	
		
		while (scanf("%d",&n)!=-1)
		{
			int counter1 = 0;
			for (int i = 0; i <= n; i++)
			{
				if (yakusuu(i) == 2) counter1++;
			}

				cout << counter1 << endl;
		}
		
		
	return 0;
}