Multiplicative persistence Multiplicative Persistence


Multiply all the digits in a number
Repeat until you have a single digit left


As explained by Numberphile:


Numberphile "What's special about 277777788888899?"
Numberphile "Multiplicative Persistence (extra footage)"


Example


277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872  
4996238671872 → 4x9x9x6x2x3x8x6x7x1x8x7x2 = 438939648  
438939648 → 4x3x8x9x3x9x6x4x8 = 4478976  
4478976 → 4x4x7x8x9x7x6 = 338688  
338688 → 3x3x8x6x8x8 = 27648  
27648 → 2x7x6x4x8 = 2688  
2688 → 2x6x8x8 = 768  
768 → 7x6x8 = 336  
336 → 3x3x6 = 54  
54 → 5x4 = 20  
20 → 2x0 = 0


This is the current record, by the way: the smallest number with the largest number of steps.

Golf

A program that takes any whole number as input and then outputs the result of each step, starting with the input itself, until we hit a single digit. For 277777788888899 the output should be

277777788888899
4996238671872
438939648
4478976
338688
27648
2688
768
336
54
20
0


(Counting the number of steps is left as an exercise to the user).

More Examples

From A003001:

25
10
0


From A003001 as well:

68889
27648
2688
768
336
54
20
0


From the Numberphile video:

327
42
8




So there has been a question about Additive Persistence, but this is Multiplicative Persistence. Also, that question asks for the number of steps as output, while I'm interested in seeing the intermediate results.
TI-BASIC (TI-84), 30 32 31 bytes

-1 byte thanks to @SolomonUcko!

While Ans&gt;9:Disp Ans:prod(int(10fPart(Ans10^(seq(-X-1,X,0,log(Ans:End:Ans


Input is in Ans.
Output is displayed as the challenge requests.  The trailing Ans is needed to print the last step.

I will admit, I did not think of this formula myself, rather I found it here and modified it to better fit the challenge.

EDIT:  Upon rereading the challenge, I realized that the program must terminate if the product is one digit.  Hence, 2 bytes were to be added to account for this.

Example:

24456756
        24456756
prgmCDGF8
        24456756
          201600
               0
11112
           11112
prgmCDGF8
           11112
               2


Explanation:

While Ans&gt;9               ;loop until the product is one digit
Disp Ans                  ;display the current product
prod(                     ;get the product of...
 int(                     ; the integer part of...
  10fPart(                ; ten times the fractional part of...
  Ans                     ; each element in the following list times the
                          ;  current product
  10^(                    ; multiplied by the list generated by using each
                          ;  element of the following list as an exponent
                          ;  for 10^n
   seq(-X-1),X,0,log(Ans  ; generate a list of exponents from -1 to -L where
                          ;  L = the length of the current product
End
Ans                       ;leave the final product in "Ans" and implicitly
                          ; print it


Visual Model:
Ans starts off as 125673.
This model only covers the logic behind multiplying the digits; everything else is easier to understand.

seq(-X-1,X,0,log(Ans  =&gt;  seq(-X-1,X,0,5.0992
   {-1 -2 -3 -4 -5 -6}
10^(...
   {.1 .01 .001 1E-4 1E-5 1E-6}
Ans...
   {12567.3 1256.73 125.673 12.5673 1.25673 .125673}
fPart(...
   {.3 .73 .673 .5673 .25673 .125673}
10...
   {3 7.3 6.73 5.673 2.5673 1.25673}
int(...
   {3 7 6 5 2 1}
   (the digits of the number, reversed)
prod(...
   1260
   (process is repeated again)

seq(-X-1,X,0,log(Ans  =&gt;  seq(-X-1,X,0,3.1004
   {-1 -2 -3 -4}
10^(...
   {.1 .01 .001 1E-4}
Ans...
   {126 12.6 1.26 .126}
fPart(...
   {0 .6 .26 .126}
10...
   {0 6 2.6 1.26}
int(...
   {0 6 2 1}
prod(...
   0
   (product is less than 10.  loop ends)




Notes:

TI-BASIC is a tokenized language.  Character count does not equal byte count.

10^( is this one-byte token.

This program will not provide the correct sequence of products with integers greater than 14 digits long due to the limitations of decimal precision on the TI calculators.