Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Solve using MATLAB live script 1. (40 points) The number 6174 is known as Kaprekars constant after the Indian Mathematician D. R. Kaprekar. This number

Solve using MATLAB live script

image

1. (40 points) The number 6174 is known as Kaprekars constant after the Indian Mathematician D. R. Kaprekar. This number is notable for the following rules: The above process, knowns as Kaprekars routine, will always converge to a fixed point, 6174, in at most 7 iterations. For example, if 3524 is chosen then arranging the digits in descending order yields 5432 and arranging the digits in ascending order yields 2345. Subtracting the former from the latter gives 5432-2345 3087. Repeating this processes gives 1. Take any four-digit number (leading zeros are allowed) with at least two different digits. 2. Arrange the digits in descending and then in ascending order to get two different four-digit numbers, add leading zeros if necessary. 3. Subtract the small number from the bigger one. 4. Go back to step 2 and repeat. #123. The only four-digit numbers for which Kaprekar's routine does not reach 6174 are the numbers with repetitive digits such as 1111, which give the result 0000 after a single iteration. All other four-digit numbers eventually reach 6174 if leading zeros are used to keep the number of digits at 4. 3 8730-0378=8352 8532-23586174 Write a MATLAB script that randomly generates a four-digit number and perform the above mentioned process to eventually reach the Kaprekars constant, 6174. The script should display the iterations as shown below (if 3524 was randomly selected): 7641-1467 6174 Number 3087 8352 6174

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Heres a MATLAB script that randomly generates a fourdigit number and performs the Kaprekars r... 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

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions