Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

c++ CMPS 147 - Homework #3 Calculate the first N emirp (prime, spelled backwards) numbers, where N is a positive number that the user provides

c++
image text in transcribed
CMPS 147 - Homework #3 Calculate the first N emirp (prime, spelled backwards) numbers, where N is a positive number that the user provides as input. An Emirp is a prime number whose reversal is also a prime. For example, 17 is a prime and 71 is a prime, so 17 and 71 are emirps. Write a program that prints out the first Nemirps, five on each line. For example Please enter a positive number: 2 3 5 7 13 17 31 37 73 79 97 101 113 131 149 151 167 179 181 191 9 25 11 71 107 157 199 For this assignment, you are required to make use of 2 functions (which you must will bool isPrime(int value); // Returns true if value is a prime number. int reverse (int value); // Returns the reverse of the value lic. if value is 35. returns 53). You should follow a top-down design using these functions in conjunction with logic in main to perform the computation of Nemirps and print them out according to the screenshot above. The general outline for main would be as follows Step 1: Ask user for positive number (input validation) Step 2: Initialize a variable Tost to 2 Step 3: While # emirps found is less than the input: If both Call isPrime with Test, and call it again with reverse (Test). are prime, print and increment number of emiros found. Test

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Modern Database Management

Authors: Fred R. McFadden, Jeffrey Slater, Mary B. Prescott

5th Edition

0805360549, 978-0805360547

More Books

Students also viewed these Databases questions

Question

=+derived from the assignment will balance the costs?

Answered: 1 week ago

Question

=+6 Who is the peer of the IA ?

Answered: 1 week ago