простые числа
#include <iostream>
#include <cmath>
#include <iostream>
#define el "\n"
using namespace std;
bool isprime(int n)
{
if (n <= 1)
{
return 0;
}
for(int i=2 ; i <= sqrt(n); i++) // [sqrt(n)] is faster in calculations than [n/2]
{
if(n%i == 0)
{
return 0;
}
}
return 1;
};
int main()
{
long long num;
cin >> num; // ~~~ Enter a number
(isprime(num))? cout << "The number (" << num <<") is a prime" << el : cout << "The number (" << num <<") isn't a prime" << el;
return 0;
}
Determined Deer