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 <stdio.h>
const int MAX_V = 1000000;//1000000?????§????´???°??¨?????????
int prime [999999];//??¨?????????????????????????????????
int sum[1000000];//?´????????????????
int main(){
	
	int i, k, n;
	for(i = 2; i < MAX_V; i++){
		prime[i] = 1;
	}
	for(i = 2; i*i < MAX_V; i++){//??¨?????????????????????????????¨????????????
		if(prime[i] == 1){
			for(k = 2*i; k < MAX_V; k += i){
				prime[k] = 0;//?´???°????????°????´???°??§??????
			}
		}
	}
	for(i = 2; i < MAX_V; i++){//?´????????????????
		sum[i + 1] = sum[i] + prime[i];//
	}
	while(scanf("%d", &n) != EOF){
		printf("%d\n", sum[n + 1]);
	}
	return 0;
}

C++: #include <stdio.h>
#include <stdlib.h>
#include <math.h>
#pragma warning(disable:4996)

int main()
{
	int DataSet,nCnt,nCnt2,In,Total,Count;

	Total = 0;
	DataSet = 0;

	for (DataSet = 0; DataSet <= 30; DataSet++)
	{
		scanf("%d", &In);
		Total = 1;

		if (In > 2)
		{
			for (nCnt = 3; nCnt <= In; nCnt += 2)
			{
				Count = 0;

				for (nCnt2 = 3; nCnt2 <= sqrt((double)nCnt); nCnt2++)
				{
					if (nCnt%nCnt2 == 0)
					{
						if (nCnt != nCnt2)
						{
							Count++;
							break;
						}
					}
				}
				if (Count == 0)
					Total++;
			}
		}

		printf("%d\n", Total);
	}


	return 0;
}

C++: #include <stdio.h>

int CheckPrime(int n);
int main(void)
{
	static int IsPrime[1000000];
	int i, n, ans;

	for(i=0; i<=999999; i++)
		IsPrime[i]=-1;

	while(scanf("%d",&n)!=EOF)
	{
		ans = 0;
		for(i=2; i<=n; i++)
		{
			if(IsPrime[i] == -1)
				IsPrime[i] = CheckPrime(i);
			
			if(IsPrime[i])
				ans++;
		}
		printf("%d\n", ans);
	}
	return 0;
}

int CheckPrime(int n)
{
	int i;
	if(n <= 1)return 0;
	if(n == 2)return 1;
	if(n%2==0)return 0;

	for(i=3; i*i<=n; i++)
		if(n%i == 0)return 0;

	return 1;
}

C++: #include <iostream>
#include <iomanip>
#include <sstream>
#include <stdio.h>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <math.h>
#include <utility>
#include <string>
#include <ctype.h>
#include <cstring>
#include <cstdio>
#include <sstream>
#include <functional>

using namespace std;

#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define INF 1145141919
#define ll long long
//#define scanf scanf_s
bool p[1000005];
int main()
{

	REP(i, 1000000) p[i] = true;
	p[0] = p[1] = false;
	for (int i = 2; i*i <= 1000000; i++)
	{
		if (p[i] == true)
		{
			for (int j = 2; j*i <= 1000000; j++)
			{
				p[i*j] = false;
			}
		}
	}
	int n;
	while (cin >> n)
	{
		int cnt = 0;
		REP(i, n + 1)
		{
			if (p[i] == true) cnt++;
		}
		cout << cnt << endl;
	}
	return 0;
}

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

//using namespace std;

int sosuu(int n);

int main(){
    int n = 0;
    
    while(scanf("%d",&n)!=EOF){
        int temp = 0;
        if(n==1){
            printf("%d\n",0);
        }else{
            for(int i=2; i<=n; i++ ){
                temp+=sosuu(i);
                if(i!=2){
                    i++;
                }
            }
            printf("%d\n",temp);
        }
    }
}

int sosuu(int n){
    int temp=1;
    for(int i=0; i<n; i++){
        temp=temp*7;
    }
    if(temp%n!=7%n){
        return 0;
    }
    return 1
    ;
}

C++: #include<cstdio>
using namespace std;
#define max 1000000
bool p[max];
int main(){
    p[1] = true;
    for(int i = 2; i * i < max; i++){
		if(p[i]) continue;
		for(int j = i * i; j < max; j+=i) p[j] = true;
	}
    int n;
    while(~scanf("%d",&n)){
		int ans = 0;
		for(int i = 1; i <= n; i++){
			if(!p[i])ans++;
		}
		printf("%d\n",ans);
	}
    return 0;
}

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

using namespace std;

int main() {

	int n,count;

	while (cin >> n) {
		
		//?´???°????????????????¨???¶?????????????????????????¢????
		bool *is_prime;
		is_prime = (bool *)malloc(n+1);
		if (is_prime == NULL) {
			cout << "malloc error" << endl;
			break;
		}

		//2????????§????????¶??°???????????????????????????
		//????????¨????´???°??§????????¨??????
		is_prime[2] = true;
		for (int i = 3; i <= n; i+=2) {
			is_prime[i] = true;
		}

		for (int i = 3; i <= sqrt(n); i+=2) {
			//?´???°???????????§????????£???????????????????????§??????
			if (is_prime[i] == true) {
				//????????°???????????§????????°????????£?????????
				for (int j = i+2; j <= n; j+=2) {
					//cout << "i=" << i << " j=" << j << " is_prime(i)=" << is_prime[i] << " is_prime(j)=" << is_prime[j] << endl;
					if (is_prime[j] == true) {
						if (j%i == 0) {
							//????????????????????????????´???°??§?????????
							is_prime[j] = false;
						}
					}
				}
			}
		}

		//?´???°??¨?¢????????????°????????°????????????
		count = 1;  //2?????¶??°??§???????´???°????????§????????\???????????????
		for (int i = 3; i <= n; i+=2) {
			if (is_prime[i] == true) {
				count++;
				//cout << " " << i;
			}
		}

		//??¨???
		cout << count << endl;
	}
	return 0;
}

C++: #include <iostream>
using namespace std;
bool isprime(int& num)
{
    static int c;
    for(c=2; c < num; c++)
        if(num % c ==0) return false;
    return true;
}

int main()
{
    int ans = 0;
    int buff;
    while(cin >> buff);
    {
        for(int d =2; d <= buff; d++)
            if(isprime(d)) ans++;
        cout << ans << " ";
        ans  = 0;
    }
    cout << endl;
    return 0;
}

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

int main(){

	int n;

	while(std::cin>>n){

		int c2=1;	//2

		for(int i=3;i<=n;i+=2){

			int c=0;

			for(int j=3;j<=sqrt(i);j+=2){

				if(i%j==0){

					c++;
					break;

				}
			}

			if(c==0)c2++;
		}

		std::cout<<c2<<std::endl;

	}

}

C++: #include<cstdio>
#include<cmath>

long long gcd(long long a, long long b)
{
    return b?gcd(b,a%b):a;
}
long long m,n;
int main()
{
    while(~scanf("%lld%lld",&m,&n))
    {
        long long temp = gcd(m,n);
        printf("%lld %lld\n",temp,m*n/temp);
    }
    return 0;
}

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

void markMultiples(bool arr[], int a, int n)
{
    int i = 2, num;
    while ( (num = i*a) <= n )
    {
        arr[ num-1 ] = 1; 
        ++i;
    }
    
}
 

void prime_Number(int n)
{
    
    if (n >= 2)
    {
        bool arr[n];
        memset(arr, 0, sizeof(arr));
 
        for (int i=1; i<n; ++i)
        {
            if ( arr[i] == 0 )
            {
                cout<<i+1 <<endl;
                markMultiples(arr, i+1, n);
            }
        }
    }
}
 
int main()
{
    int n;
    cin>>n;
    prime_Number(n);
    
    return 0;
}

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

int main()
{
	int input;
	int i, j, k, cnt;
	bool fg;
	for(i = 0; i < 30; i++)
	{
		cin >> input;
		cnt = 0;

		for(k = 2; k <= input; k++)
		{
			fg = false;
			for(j = 2; j <= sqrt(k); j++)
			{
				if(k % j == 0)
				{
					fg = true;
					break;
				}
			}
			if(!fg) cnt++;
		}
		cout << cnt << endl;
	}
}