answersLogoWhite

0

#include<iostream>

bool is_composite (const size_t);

bool is_prime (const size_t);

int main()

{

for (size_t num=1; num<=10; ++num)

if (is_composite (num))

std::cout << num << " is composite\n";

}

bool is_composite (const size_t num)

{

if (num < 4U)

return false;

return !is_prime (num);

}

bool is_prime (const size_t num)

{

const size_t two = 2U;

if (num < two)

return false;

if (!(num % two))

return num == two;

const size_t max = static_cast<size_t>(sqrt (static_cast<double>(num)));

for (size_t div = 3U; div <= max; div += two)

if (!(num % div))

return false;

return true;

}

User Avatar

Wiki User

10y ago

What else can I help you with?

Related Questions

What are the composite numbers of 110?

10, 22, 55, 110 are the composite factors of 110.


Is 110 plus 120 a composite number?

110 + 120 = 330 330 is a composite number.


Is 110 prime or composite?

110 is composite. A prime number is a number that is divisible only by 1 and itself; it has no other factors. A composite number is a number that is divisible by more than 2 numbers. The factors of 110 are 1, 2, 5, 10, 11, 22, 55, and 110. Therefore, 110 is a composite number.


Is 110 is it prime or composite?

110 is a composite number. A prime number has only 2 factors which are 1 and itself. Composite numbers are everything else except 1 and 0. 1 and 0 are neither prime, nor composite.


Is 110 composite?

A prime number has only 2 factors which are 1 and itself. Composite numbers are everything else except 1 and 0. 1 and 0 are neither prime, nor composite. 110 is composite.


What is the composite numbers from 100 to 110?

102 104 105 106 108


What are the composite numbers from 90 to 110?

Composite numbers are positive integers greater than 1 that have factors other than 1 and themselves. In the range from 90 to 110, the composite numbers are 91, 92, 94, 95, 96, 98, 99, 100, 102, 104, 105, 106, 108, and 110. These numbers can be divided evenly by numbers other than 1 and themselves, making them composite.


Is 110 prime composite or neither?

110 is a composite number. A prime number has only 2 factors which are 1 and itself. Composite numbers are everything else except 1, 2, and 0. 1, 2, and 0 have a different name.


What are all the composite numbers 100 to 110?

100 102 104 105 106 108 110


What plus what equals 110?

To find the two numbers that add up to 110, we can set up an equation as follows: x + y = 110. Since we are looking for two numbers that add up to 110, we can choose any two numbers that satisfy this equation. For example, 60 + 50 = 110. Therefore, the two numbers that add up to 110 are 60 and 50.


What are the composite numbers from 80 to 110?

80, 81, 82, 84, 85, 86, 87, 88, 90, 91, 92, 93, 94, 95, 96, 98, 99, 100, 102, 104, 105, 106, 108, 110.


What is the composite factor of 110?

10, 22, 55, 110