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:
		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
}

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

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

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;
	}
}

C++: #include <cstdio>
#include <cmath>
#define MAX_N 1000000

int main(){
    bool p[MAX_N+1];    // p[NUM] : NUM is Prime?
    int n;

    for(int i = 0; i <= MAX_N; i++) p[i] = true;

    for(int i = 1; i <= MAX_N; i++){
        if(i == 1) p[i] = false;
        else{
            if(p[i]){
                for(int j = 2; i * j <= MAX_N; j++){
                   p[i*j] = false;
                }
            }
        }
    }
 
    // for(int i = 0; i <= MAX_N; i++) if(p[i]) printf("%d\n",i);
    
    while(scanf("%d", &n) == 1){
        int count = 0;
        for(int i = 1; i <= n; i++){
            if(p[i])count++;
        }
        printf("%d\n", count);
    }
    return 0;
}

C++: #include <iostream>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <limits>
#include <map>
#include <string>
using namespace std;

bool is_prime(int n){
for(int i=2;i*i<=n;i++){
if(n % i == 0) return false;
}
return n!=1;
}

int main(){
int n;

while(~scanf("%d",&n)){
int* table =  new int[1000000];
fill((int*)table,(int*)table+sizeof(table),1);
table[0]=0;

for(int i=1;i<=n;i++){
if(!is_prime(i)) {
for(int j=i;j<=n;j*=i){
table[j] = 0;
}
}
}
printf("%d\n",count(table,table+1000000,1));
}
}