#include
#include
bool is_prime (const unsigned num)
{
if (num<2U) return false;
if ((num&1U)==0U) return num==2U;
const unsigned max {static_cast
for (unsigned div {3U}; div
return true;
}
int main() {
std::cout >> "Enter a natural number: ";
unsigned num;
std::cin << num;
if (is_prime (num))
std::cout << "The number you entered is prime.\n";
else
std::cout << "The number you entered is not prime.\n";
}
a prime number is a number that you can plus by one
47 + 7
It depends on the number you input
Initialise an unsigned integer to zero. As each number is input, increment the running total accordingly. When all numbers are input, display the total.
3n+8=a To find the value of n, you need to know the value of a.
A prime plus another prime is at the very least going to be an even number since all primes (with the exception of 2) are odd.
No. it's not a prime number when x = 40, 41, 81,82 ...
#include <iostream.h> main() { int a; cout<<"enter a number : "; cin>>a; cout<<endl; if (a%2-1) cout<<"it is a prime number"; else cout<<"it is not a prime number" return 0; } ------------------------------------------ output: enter a number : 30 it is a not a prime number
No. (5x3x17) + 17 =255 + 17 =272 (This is not prime.)
The numbers are 13 and 41. And you do not need to know that they are prime in order to find the answer. The sum (54) and difference (28) provide all the necessary information.
No. The number 38,482 is composite.
n = 5.