answersLogoWhite

0

#include <iostream>

bool isPrime(int p)

{ if( p<=1 ( p>2 && p%2==0 ))return( false );int max = (int)sqrt(( double ) p ) + 1;

for( int i=3; i<=max; i+=2 )if( p%i==0 )return( false );return( true );

}

int main()

{ for( int i=1; i<100; i>2?i+=2:++i )if( isPrime(i) )std::cout << i << std::endl;return( 0 );

}

User Avatar

Wiki User

12y ago

What else can I help you with?

Related Questions

How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


What is 1000 plus 100?

The answer is 1100. Simply add the numbers together arithmetically as you would for the problem two plus two. To check your work, a calculator is the best option.


What are prime number and composite numbers?

a prime number is a number that you can plus by one


Factor the polynomial. If it is prime type PRIME. x2 plus 5x plus 4?

It is: (x+1)(x+4) none of which are prime numbers


Is 4 plus 6 a prime number of 20?

NO!!!! Other than '2' all prime numbers are odd numbers. 4,6,10 &amp; 20 are all even so they are not prime numbers.


How many prime numbers between 2000 and 3000?

127 prime numbers in that range. See related link for prime numbers up to 10000. Plus there is a link to download Zip files of prime numbers up to 1 million.


100 plus 1000 equals?

Well, honey, 100 plus 1000 equals 1100. It's basic math, darling. Keep those numbers in line and you'll be just fine.


What is P plus P plus N in prime numbers?

It would always be a natural number.


What two prime numbers equal 98?

19 plus 79


What are to prime numbers to make 30?

They are 23 plus 7 = 30


What two numbers does the primorial formula prime number plus or minus 1 produce for prime equals 11 which if either of these numbers is prime?

11# - 1 = 2309 and 11# + 1 = 2311, both of which are prime.


What two numbers does the primorial formula prime number plus or minus 1 produce for prime equals 7 which if either of these numbers is prime?

p7# - 1 = 510509 and p7# + 1 = 510511, neither of which is prime.