Question
Open the power_of_primes.cpp file and update the file to perform the following: (a) Prompt the user to enter a non-negative integer x and read the
Open the power_of_primes.cpp file and update the file to perform the following: (a) Prompt the user to enter a non-negative integer x and read the value (you are not required to check if the input is non-negative; just assume it is). (b) Write the logic which checks if x can be written as a power of two primes; that is, check if there exist two prime integers a and b such that x = ab. If you can write x as a power of primes, print \"Yes\" and print these primes that you found; otherwise, print \"No, x cannot be written as a power of primes\". Hints: An integer n is prime if n > 2 and n does not have any divisor other than 1 and itself. The logic for checking if an integer is prime or not is already given to you in the function is Prime which is provided above main (do not worry, you are not expected to understand the syntax because you did not learn about functions yet). Thus, you are not required to write the logic to check if a and b are prime; instead, you can directly use the given function. For example, you can write isPrime(a) to check if a is prime; this will give you a Boolean value: true if a is prime and false otherwise. (c) Ask the user to enter another integer N (assume it is positive), and print the first N positive integers which satisfy the condition in part b: for each one of these, print the corresponding primes (see the sample inputs/outputs below),
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started