Website Summary Files Commits Branches @commit @diff @stats
path: root / Sem. 6 / Task_1(with functions).cpp
blob: db68d0dcd2d94fff81c6c22b30effac9f8acd3b3 (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
#include <iostream>
using namespace std;

bool isPrime(int number)
{
	double temp = sqrt(number);
	for (int i = 2; i <= temp; i++)
	{
		if (number % 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;
	}

}