Question: PLEASE USE ONLY #include and not: #include , etc. if you can. Thanks! In this project, you will write a program that uses loops to

PLEASE USE ONLY #include and not: #include, etc. if you can. Thanks!

In this project, you will write a program that uses loops to decompose an integer greater than or equal to two into a product of powers of its prime factors.

Definition 1. A prime number, or simply a prime, is an integer greater than or equals to 2 whose only factors are 1 and itself. The first eight primes are 2, 3, 5, 7, 11, 13, 17 and 19.

Definition 2. The factorization of a number into its constituent primes called prime decomposition is the expression of a number as a product of powers of primes. Given a positive integer n 2, the prime factorization is written as n = p a1 1 p a2 2 p ak k , where each of the k pis is a prime and each ai is the number of times that pi appears as a factor of n. For example, the prime decomposition of 90 is 2 3 3 5 or 2 3 2 5.

The PrimeDecomposer Program

Write a C++ program the generates the prime factorization of an integer. The program should prompt the user to enter an integer greater than one and compute its prime decomposition. If the user enters an integer that is less than two, the program displays a message indicating that only integers greater than one can be expressed as a product of prime factors. If the user enters an integer greater than one, the program generates the prime decompositition of the integer.

To generate the prime factorization of an integer, the program follows these steps:

1. It determines the smallest prime factor of the number.

2. It counts the number of times that the smallest factor appears as a factor of the number. For every update of the count, it updates the number by replacing it with the quotient of the current value of the number and the factor.

3. It displays the first power of a prime factor as shown in the sample run. It should not display one as an exponent.

4. As long as the number is not one, it does the following:

(a) It determines the next factor of the number.

(b) It counts the number of times that the next factor appears as a factor of the number. For every update of the count, it updates the number by replacing it with the quotient of the current value of the number and the factor.

(c) It displays the power of the factor as shown in the sample run. It should not display one as an exponent.

Write the program incrementally. First write code that prints a message when the user enters an integer less than two. Next, write code to compute the power of the smallest prime factor of the number. After you get this to work, add a nested loop to determine the remaining factors of powers of primes. Your program should avoid the use of unnecessary variables. Reuse variables whenever possible. Typical sample runs of the program should appear as shown below:

PLEASE USE ONLY #include and not: #include, etc. if you can. Thanks!

Listing1: Sample Run 1 Enter an integer to conpute ite prine deconposition1 2 cannot be expressed as a product of prine povera Listin Enter an integer to conpute its prise decosposttion2 Listing 3 1 Enter an integer to cospute its priae decosposition-17 Listing 4: 1 Enter an integer to cospute its priae decosposition >64 2 64-2-6 5c Run Eater an isteger to cospute its prise decosposition- 7429 2 7429-17 x 19 z 23 6: Run 1 Enter an integer to cospute its prise decosposicion- 8000 2 8000-2"6 x 5*3 7: Run 1 Enter an integer to cospute its prine decosposition21000 2 21000 23 z 3 x 5-3 1 7 8: Run 1 Enter an integer to compute its prime decomposition 18907875 2 18907875= 3.25.3x 7-5

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!