Question: using c++ Background A prime number is an integer number greater than 1 that has no positive divisors other than one and itself. Directions Write

 using c++ Background A prime number is an integer number greaterthan 1 that has no positive divisors other than one and itself.

using c++

Background A prime number is an integer number greater than 1 that has no positive divisors other than one and itself. Directions Write a program that will prompt the user for an integer n that will be tested to determine if it is a prime number. The best approach is to start by assuming the integer n is prime by creating a Boolean variable (isPrime=True) and attempting to prove it is not prime by testing it to find a number i that divides it evenly using the modulo (remainder) operator (i.e. if n%i==0). Use a loop (a for loop is easiest) to repeatedly test the integer n to see if an i = 2, 3, 4, 5, ... etc. up to n-1, is a divisor of the integer. If you find a number that divides n evenly then you have proven that the number is not prime (isPrime=False) and the program breaks (beak statement) from the loop. If a divisor is found to prove that the integer n is not prime, then output the smallest number that evenly divides the integer n. If all possibilities are exhausted and no divisor was found that evenly divides integer n then the number must be prime (if isPrime==True) First 100 Prime Numbers 2 31 73 127 179 233 283 353 419 467 3 37 79 131 181 239 293 359 421 479 5 41 83 137 191 241 307 367 431 497 7 43 89 139 193 251 311 373 433 491 11 47 97 149 197 257 313 379 439 499 13 53 101 151 199 263 317 383 443 503 17 59 103 157 211 269 331 389 449 509 19 61 107 163 223 271 337 397 457 521 23 67 109 167 227 277 347 401 461 523 29 71 113 173 229 281 349 409 463 541 See tests output below for example operation. Test 1 Output Check to see if your number is prime or composite. Enter a whole number to test: 101 The nunber 101 is a prime number! Test 2 Output Check to see if your number is prine or composite. Enter a whole number to test: 10013 The nunber 19013 is not prine because it is divisible by 17. 301720.1782130.qx3zqy7 LAB ACTIVITY 4.17.1: LAB: Prime Number Finder 0/20 Downloadable files main.cpp Download main.cpp Load default template... 1 #include 2 using namespace std; 4 int main() { return 0; 7 8 9}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!