Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Persistent Numhers The multiplicative persistence of a number is defined by Neil Sloane (Ne J.A. Sloane in The Persistence of a Number published in Journal
Persistent Numhers The multiplicative persistence of a number is defined by Neil Sloane (Ne J.A. Sloane in The Persistence of a Number published in Journal of Recreational Mathematics 6, 1973, pp. 97-98., 1973) as the number of steps to reach a single-digit number when repeatedly multiplying the digits. For example 679-378>168 48-32>6 That is, the persistence of 679 is 5" Likewise, the persistence of 10-> 1 . As one can imagine, th persistence of (such as 277777788888899) but it is not known whether there are numbers with the persistence of 12 However, it is known that if such number do exist, the smallest of them would have more than 3000 digits in it. Some fun facts about persistence: e persistence of a single digit number is 0. As of now, it is known that there are numbers with the The smallest number of persistence s 10 The smallest number of persistence 2 is 25 The smallesi number ofpersistence 3 is 39 The smallest number of persistence 4 is 77 The smallest number of persistence 5 i 679 The smallest number of persistence 6 6788 The smallest number of persistence 7 is 68889 The smallest number ofpersistence 8 is 2677889 The smallest number of persistence 9 is 26888999 The smallest number of persistence 10 is 3778888999 You have been given a list of 125 9-digit numbers in an ASCII text file such that each number is on a separate line. There are two parts of this homework assignment. PART I 1. In this part, you will be writing another simple C program such that the program will take name ofthe input file as command line argument name of the input file text file. If there is no argument, it should write a usage message (indicating how to use this program) and terminate. Otherwise, it should recover the argument and from the provided file, read the list of numbers 2. Now sort the list within the program in ascending order using any sorting algorithm that you may know or have studied in the past. No external sorting or call to any sorting utility is allowed 3. Calculate persistence of each of the number in the sorted list. 4. Find the number with the smallest and the largest persistence values and print both the numbers and their corresponding persistence values. 5. Calculate the CPU time it takes to do the entire set of steps 1 -4 and print the CPU time
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