Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 04 / example01_with_functions.cpp
blob: 64d4367face4d38f64ab6e7c47e5157c66ddba43 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <iostream>
using namespace std;

bool isPrime(unsigned n)
{
	if(n <= 1)
		return false;

	double temp = sqrt(n);

	for (int i = 2; i <= temp; i++)
	{
		if (n % i == 0)
			return false;
	}

	return true;
}

int main()
{
	int n;
	cin >> n;

	for (int i = 6; i < n; i += 6)
	{
		if (isPrime(i - 1) && isPrime(i + 1))
			cout << i - 1 << " " << i + 1 << endl;
	}
}