00:01
Hello student, here i have to find the capricor's constant.
00:07
Here is given we have to reach towards the capricor's constant.
00:10
Capricor's constant is a number of the four digits which value is 6174.
00:15
So i have to calculate how to reach towards the capricor's constant and i have to find out the number of iteration in how many step i reach towards the capricor's constant.
00:26
So here i have written the function capricor's constant.
00:29
Here i am sending the argument number.
00:31
Calculate the sequence of the number to reach 6174 using the capricor's routine.
00:36
Argument here is number and integer between so it must be four digit number.
00:40
Returns a tuple of the two list the sequence of the number to reach 6174 and second one number of the iteration.
00:47
So convert the number to a string.
00:49
So first work is to convert the number into a string.
00:51
So here which number i will send that number is converted into a string and stored in number underscore string.
00:57
So now so if the number is not four digit pairs the number with the zeros which has fewer than four digits.
01:04
So here if length is length of the string is length underscore number underscore string is less than four then we have to add the zeros leading zeros by calculating four minus length plus a number of strings number underscore string.
01:20
Now sort the number in ascending and descending order.
01:23
So we will apply the sorting first by setting reverse equal to true it means it is descending order and second we will do the sorting in ascending underscore digit so number underscore string we will send as an argument.
01:38
Now subtract the smaller number from the bigger to get a new four digit number.
01:43
So here it is a string type data.
01:45
So we i have to do the type casting.
01:47
So integer type casting is done and after this subtraction is done.
01:53
After this repeat the process until we reach towards 6174 because according to caprecors we have to reach towards this number so because it is caprecors constant.
02:04
So here i said the iteration one while new number is not equal to 6174 convert the new number to a string...