Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Base code: Exercise 1. (30 points) Prime factorization. Finding prime factors for large integers is a difficult problem. However, doing so for small integers is
Base code:
Exercise 1. (30 points) Prime factorization. Finding prime factors for large integers is a difficult problem. However, doing so for small integers is not hard. In this assignment, you will implement a function factor integer () that finds all prime factors of a given an unsigned integer n>1. The prototype of the function is: unsigned int * factor_integer (unsigned int n, unsigned int *nf); factor_integer() must find all prime factors of n and store them in a dynamically allocated array in non-decreasing order. It then returns the starting address of the array. The number of prime factors in the array is stored in an integer pointed to by nf. The product of all elements in the factor array should be exactly n. factor_integer() should return NULL if n is 0 or 1. For example, if n is 20, the returned array has three elements: 2, 2, 5, and *nf is 3. If n is 7, the returned array has one element: 7, and *nf is 1. Here are some sample sessions of running the program. You can use a calculator to check that the number is indeed the product of all reported prime factors. $./factor 64 64=2 * 2 * 2 * 2 * 2 * 2 $./factor 192 192=2 * 2 * 2 * 2 * 2 * 2 * 3 $./factor 123456789 123456789=3 * 3 * 3607 * 3803 $./factor 1234567890 1234567890=2 * 3 * 3 * 5 * 3607 * 3803 ./factor 1999999973 1999999973=1999999973 ./factor 2000000000 2000OONNNN=? * 2 * 2 * 2 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 * 5 1 #includeStep 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