Multiplicative persistence












39












$begingroup$


Multiplicative Persistence




  1. Multiply all the digits in a number

  2. Repeat until you have a single digit left


As explained by Numberphile:





  • Numberphile "What's special about 277777788888899?"


  • Numberphile "Multiplicative Persistence (extra footage)"


Example




  1. 277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872

  2. 4996238671872 → 4x9x9x6x2x3x8x6x7x1x8x7x2 = 438939648

  3. 438939648 → 4x3x8x9x3x9x6x4x8 = 4478976

  4. 4478976 → 4x4x7x8x9x7x6 = 338688

  5. 338688 → 3x3x8x6x8x8 = 27648

  6. 27648 → 2x7x6x4x8 = 2688

  7. 2688 → 2x6x8x8 = 768

  8. 768 → 7x6x8 = 336

  9. 336 → 3x3x6 = 54

  10. 54 → 5x4 = 20

  11. 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.










share|improve this question











$endgroup$












  • $begingroup$
    Bonus: find a new record: smallest number with the largest number of steps. Caveat: conjecture has it that 11 is the largest possible.
    $endgroup$
    – SQB
    Mar 21 at 14:31






  • 7




    $begingroup$
    You probably should include a few more tests cases that do not end with $0$.
    $endgroup$
    – Arnauld
    Mar 21 at 14:33










  • $begingroup$
    Came to make this post, found it already existing, gg
    $endgroup$
    – cat
    Mar 21 at 14:55










  • $begingroup$
    is a single digit valid input?
    $endgroup$
    – dzaima
    Mar 21 at 18:30






  • 1




    $begingroup$
    In the Numberphile video, Matt Parker states that searches have been done to several hundred digits.
    $endgroup$
    – HardScale
    Mar 21 at 21:46
















39












$begingroup$


Multiplicative Persistence




  1. Multiply all the digits in a number

  2. Repeat until you have a single digit left


As explained by Numberphile:





  • Numberphile "What's special about 277777788888899?"


  • Numberphile "Multiplicative Persistence (extra footage)"


Example




  1. 277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872

  2. 4996238671872 → 4x9x9x6x2x3x8x6x7x1x8x7x2 = 438939648

  3. 438939648 → 4x3x8x9x3x9x6x4x8 = 4478976

  4. 4478976 → 4x4x7x8x9x7x6 = 338688

  5. 338688 → 3x3x8x6x8x8 = 27648

  6. 27648 → 2x7x6x4x8 = 2688

  7. 2688 → 2x6x8x8 = 768

  8. 768 → 7x6x8 = 336

  9. 336 → 3x3x6 = 54

  10. 54 → 5x4 = 20

  11. 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.










share|improve this question











$endgroup$












  • $begingroup$
    Bonus: find a new record: smallest number with the largest number of steps. Caveat: conjecture has it that 11 is the largest possible.
    $endgroup$
    – SQB
    Mar 21 at 14:31






  • 7




    $begingroup$
    You probably should include a few more tests cases that do not end with $0$.
    $endgroup$
    – Arnauld
    Mar 21 at 14:33










  • $begingroup$
    Came to make this post, found it already existing, gg
    $endgroup$
    – cat
    Mar 21 at 14:55










  • $begingroup$
    is a single digit valid input?
    $endgroup$
    – dzaima
    Mar 21 at 18:30






  • 1




    $begingroup$
    In the Numberphile video, Matt Parker states that searches have been done to several hundred digits.
    $endgroup$
    – HardScale
    Mar 21 at 21:46














39












39








39


4



$begingroup$


Multiplicative Persistence




  1. Multiply all the digits in a number

  2. Repeat until you have a single digit left


As explained by Numberphile:





  • Numberphile "What's special about 277777788888899?"


  • Numberphile "Multiplicative Persistence (extra footage)"


Example




  1. 277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872

  2. 4996238671872 → 4x9x9x6x2x3x8x6x7x1x8x7x2 = 438939648

  3. 438939648 → 4x3x8x9x3x9x6x4x8 = 4478976

  4. 4478976 → 4x4x7x8x9x7x6 = 338688

  5. 338688 → 3x3x8x6x8x8 = 27648

  6. 27648 → 2x7x6x4x8 = 2688

  7. 2688 → 2x6x8x8 = 768

  8. 768 → 7x6x8 = 336

  9. 336 → 3x3x6 = 54

  10. 54 → 5x4 = 20

  11. 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.










share|improve this question











$endgroup$




Multiplicative Persistence




  1. Multiply all the digits in a number

  2. Repeat until you have a single digit left


As explained by Numberphile:





  • Numberphile "What's special about 277777788888899?"


  • Numberphile "Multiplicative Persistence (extra footage)"


Example




  1. 277777788888899 → 2x7x7x7x7x7x7x8x8x8x8x8x8x9x9 = 4996238671872

  2. 4996238671872 → 4x9x9x6x2x3x8x6x7x1x8x7x2 = 438939648

  3. 438939648 → 4x3x8x9x3x9x6x4x8 = 4478976

  4. 4478976 → 4x4x7x8x9x7x6 = 338688

  5. 338688 → 3x3x8x6x8x8 = 27648

  6. 27648 → 2x7x6x4x8 = 2688

  7. 2688 → 2x6x8x8 = 768

  8. 768 → 7x6x8 = 336

  9. 336 → 3x3x6 = 54

  10. 54 → 5x4 = 20

  11. 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.







code-golf math arithmetic repeated-transformation






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited 2 days ago







SQB

















asked Mar 21 at 14:20









SQBSQB

479314




479314












  • $begingroup$
    Bonus: find a new record: smallest number with the largest number of steps. Caveat: conjecture has it that 11 is the largest possible.
    $endgroup$
    – SQB
    Mar 21 at 14:31






  • 7




    $begingroup$
    You probably should include a few more tests cases that do not end with $0$.
    $endgroup$
    – Arnauld
    Mar 21 at 14:33










  • $begingroup$
    Came to make this post, found it already existing, gg
    $endgroup$
    – cat
    Mar 21 at 14:55










  • $begingroup$
    is a single digit valid input?
    $endgroup$
    – dzaima
    Mar 21 at 18:30






  • 1




    $begingroup$
    In the Numberphile video, Matt Parker states that searches have been done to several hundred digits.
    $endgroup$
    – HardScale
    Mar 21 at 21:46


















  • $begingroup$
    Bonus: find a new record: smallest number with the largest number of steps. Caveat: conjecture has it that 11 is the largest possible.
    $endgroup$
    – SQB
    Mar 21 at 14:31






  • 7




    $begingroup$
    You probably should include a few more tests cases that do not end with $0$.
    $endgroup$
    – Arnauld
    Mar 21 at 14:33










  • $begingroup$
    Came to make this post, found it already existing, gg
    $endgroup$
    – cat
    Mar 21 at 14:55










  • $begingroup$
    is a single digit valid input?
    $endgroup$
    – dzaima
    Mar 21 at 18:30






  • 1




    $begingroup$
    In the Numberphile video, Matt Parker states that searches have been done to several hundred digits.
    $endgroup$
    – HardScale
    Mar 21 at 21:46
















$begingroup$
Bonus: find a new record: smallest number with the largest number of steps. Caveat: conjecture has it that 11 is the largest possible.
$endgroup$
– SQB
Mar 21 at 14:31




$begingroup$
Bonus: find a new record: smallest number with the largest number of steps. Caveat: conjecture has it that 11 is the largest possible.
$endgroup$
– SQB
Mar 21 at 14:31




7




7




$begingroup$
You probably should include a few more tests cases that do not end with $0$.
$endgroup$
– Arnauld
Mar 21 at 14:33




$begingroup$
You probably should include a few more tests cases that do not end with $0$.
$endgroup$
– Arnauld
Mar 21 at 14:33












$begingroup$
Came to make this post, found it already existing, gg
$endgroup$
– cat
Mar 21 at 14:55




$begingroup$
Came to make this post, found it already existing, gg
$endgroup$
– cat
Mar 21 at 14:55












$begingroup$
is a single digit valid input?
$endgroup$
– dzaima
Mar 21 at 18:30




$begingroup$
is a single digit valid input?
$endgroup$
– dzaima
Mar 21 at 18:30




1




1




$begingroup$
In the Numberphile video, Matt Parker states that searches have been done to several hundred digits.
$endgroup$
– HardScale
Mar 21 at 21:46




$begingroup$
In the Numberphile video, Matt Parker states that searches have been done to several hundred digits.
$endgroup$
– HardScale
Mar 21 at 21:46










44 Answers
44






active

oldest

votes













1 2
next












13












$begingroup$

TI-BASIC (TI-84), 30 32 bytes



While Ans>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-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>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-X-1),X,0,log(Ans:End:Ans  ;full program

While Ans>9 End ;loop until the product is one digit
Disp Ans ;print the current number
prod( ;get the product of
seq( ;the list generated by
10^(-X-1), ;consecutive powers of ten
X, ;using X as the increment variable
0, ;starting at 0
log(Ans ;ending at the length of the current number
;(implicit increment by 1)
Ans ;multiplied by the current number
fPart( ;then taking the fractional part of each element
10 ;multiplied by 10
int( ;then truncating each element
Ans ;output last step since it was skipped


Visual Model:
Ans starts off as 125673.

This model only covers the logic behind multiplying the digits; everything else is easier to understand.



seq(10^(-X-1),X,0,log(Ans  =>  seq(10^(-X-1),X,0,5.0992
{.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(10^(-X-1),X,0,log(Ans => seq(10^(-X-1),X,0,3.1004
{.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.






share|improve this answer











$endgroup$





















    11












    $begingroup$


    K (ngn/k), 9 bytes



    {*/.'$x}


    Try it online!



    { } keep applying the function in curly braces until the sequence converges



    $x format the argument as a string (list of characters)



    .' evaluate each (other dialects of k require a colon, .:')



    */ times over, i.e. product






    share|improve this answer











    $endgroup$





















      8












      $begingroup$


      dzaima/APL, 14 11 bytes



      ∪{×/⍎¨⍕⍵}⍡≡


      Try it online!






      share|improve this answer











      $endgroup$





















        8












        $begingroup$


        R, 59 bytes





        n=scan();while(print(n)>9)n=prod(n%/%10^(nchar(n):1-1)%%10)


        Try it online!



        Since print invisibly returns its input, we can use print(n) inside the while loop to simulate a do-while loop. This is inspired by one of my tips for golfing in R.



        The header helps prevent large numbers from being printed in scientific notation.






        share|improve this answer











        $endgroup$





















          8












          $begingroup$


          05AB1E, 7 4 bytes



          Δ=SP


          Try it online or verify all test cases.



          Explanation:





          Δ     # Loop until the number no longer changes:
          = # Print the number with trailing newline (without popping the number itself)
          # (which will be the implicit input in the first iteration)
          SP # Convert the number to a list of digits, and calculate its product





          share|improve this answer











          $endgroup$





















            7












            $begingroup$


            Perl 6, 23 bytes





            {$_,{[*] .comb}…10>*}


            Try it online!






            share|improve this answer









            $endgroup$





















              7












              $begingroup$


              Python 2,  46  43 bytes





              -3 thanks to xnor (chained comparison)



              def f(n):print n;n>9>f(eval('*'.join(`n`)))


              Try it online!






              share|improve this answer











              $endgroup$













              • $begingroup$
                You can do > in place of and.
                $endgroup$
                – xnor
                2 days ago










              • $begingroup$
                @xnor thanks, easy to forget that will work.
                $endgroup$
                – Jonathan Allan
                2 days ago



















              6












              $begingroup$


              Wolfram Language (Mathematica), 47 bytes



              Most@FixedPointList[Times@@IntegerDigits@#&,#]&


              Try it online!






              share|improve this answer









              $endgroup$





















                6












                $begingroup$


                Wolfram Language (Mathematica), 45 bytes



                #//.x_/;x>9:>Times@@IntegerDigits@x&&Print@x&


                Try it online!






                share|improve this answer









                $endgroup$





















                  6












                  $begingroup$


                  Jelly, 4 bytes



                  DP$Ƭ


                  Try it online!



                  Explanation



                  D    | convert to decimal digits
                  P | take the product
                  $ | previous two links as a monad
                  Ƭ | loop until no change, collecting all intermediate results


                  As a bonus, here's a TIO which will find the numbers with the largest number of steps for a given range of numbers of digits. It scales well even on TIO.






                  share|improve this answer











                  $endgroup$





















                    5












                    $begingroup$


                    Julia 0.7, 36 bytes





                    f(n)=n>9?[n,f(prod(digits(n)))...]:n


                    Try it online!






                    share|improve this answer









                    $endgroup$





















                      5












                      $begingroup$


                      PowerShell, 54 bytes





                      for($a=$args;$a-gt9){$a;$a=("$a"|% t*y)-join"*"|iex}$a


                      Try it online!





                      Iterative method that first writes the input argument, then converts it into a string and pipes it into a character array. This array is joined by a single asterisks, and executed as a command with the invoke expression alias. Since this writes Starting number down to the last number greater than 0, (20, in the given test scenario), I add a final $a to the end to output.






                      share|improve this answer











                      $endgroup$





















                        5












                        $begingroup$


                        C# (Visual C# Interactive Compiler), 79 74 68 bytes





                        void f(int a){Print(a);if(a>9)f((a+"").Aggregate(1,(j,k)=>k%48*j));}


                        I try to stay away from recursion in C# due to how long the method declaration is, but in this case it saves compared to a loop.



                        Try it online!






                        share|improve this answer











                        $endgroup$





















                          5












                          $begingroup$


                          Python 2, 61 62 59 bytes





                          def f(n):print n;n>9and f(reduce(int.__mul__,map(int,`n`)))


                          Try it online!



                          -3 bytes, thanks to Jonathan Allan






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                            $endgroup$
                            – Embodiment of Ignorance
                            Mar 21 at 15:40










                          • $begingroup$
                            int.__mul__ is three bytes less than lambda a,b:a*b
                            $endgroup$
                            – Jonathan Allan
                            Mar 21 at 17:17










                          • $begingroup$
                            @JonathanAllan Thanks! I knew there had to be something like that
                            $endgroup$
                            – TFeld
                            Mar 21 at 19:05










                          • $begingroup$
                            Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                            $endgroup$
                            – mypetlion
                            Mar 21 at 20:34












                          • $begingroup$
                            @mypetlion ...I already did that in another post.
                            $endgroup$
                            – Jonathan Allan
                            Mar 21 at 20:52



















                          5












                          $begingroup$

                          perl 5 (-n -M5.01), 32 30 25 bytes



                          say$_=eval;s/B/*/g&&redo


                          25 bytes



                          30 bytes



                          32 bytes






                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            You should mention that this uses -lpF//
                            $endgroup$
                            – Grimy
                            2 days ago






                          • 1




                            $begingroup$
                            @Grimy i could save 2 bytes without using -lpF//, updating
                            $endgroup$
                            – Nahuel Fouilleul
                            2 days ago



















                          5












                          $begingroup$


                          MathGolf, 9 10 bytes



                          h(ôo▒ε*h(→


                          Try it online!



                          Now it correctly handles inputs that are single digits. Not perfect, but at least it is correct.



                          Explanation



                          h(            check length of input number and decrease by 1
                          ö → while true with pop using the next 6 operators
                          p print with newline
                          ▒ split to list of chars/digits
                          ε* reduce list by multiplication
                          h( length of TOS without popping, subtracted by 1 (exits when len(TOS) == 1)





                          share|improve this answer











                          $endgroup$













                          • $begingroup$
                            The output for a single digit input should be one copy of the number - clarified in the comments
                            $endgroup$
                            – dzaima
                            Mar 21 at 18:38










                          • $begingroup$
                            @dzaima I'll look into it, and update the answer when it's solved
                            $endgroup$
                            – maxb
                            2 days ago



















                          4












                          $begingroup$

                          JavaScript (ES6), 45 bytes



                          Returns an array of integers.





                          f=n=>[n,...n>9?f(eval([...n+''].join`*`)):]


                          Try it online!






                          share|improve this answer











                          $endgroup$





















                            4












                            $begingroup$


                            PowerShell, 51 bytes





                            filter f{$_
                            if($_-gt9){("$_"|% t*y)-join'*'|iex|f}}


                            Try it online!






                            share|improve this answer









                            $endgroup$





















                              4












                              $begingroup$

                              Haskell, 45 bytes



                              f n=n:[x|n>9,x<-f$product$read.pure<$>show n]


                              Try it online!






                              share|improve this answer









                              $endgroup$





















                                4












                                $begingroup$


                                PHP, 63 bytes





                                <?=$n=$argn;while($n>9)echo"
                                ",$n=array_product(str_split($n));


                                Iterative version, call with php -nF input from STDIN.



                                Try it online!




                                PHP, 72 71 bytes





                                function h($n){echo"$n
                                ",($n=array_product(str_split($n)))>9?h($n):$n;}


                                Try it online!



                                Recursive version, as function.



                                Input: 277777788888899



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


                                Input: 23



                                23
                                6





                                share|improve this answer











                                $endgroup$





















                                  4












                                  $begingroup$


                                  J, 16 bytes



                                  ([:*/,.&.":)^:a:


                                  Try it online!






                                  share|improve this answer









                                  $endgroup$





















                                    4












                                    $begingroup$


                                    Ruby, 38 35 34 bytes





                                    f=->n{p(n)>9&&f[eval n.digits*?*]}


                                    Try it online!



                                    1 byte saved by by G B.






                                    share|improve this answer











                                    $endgroup$





















                                      3












                                      $begingroup$


                                      Brachylog, 7 bytes



                                      ẉ?Ḋ|ẹ×↰


                                      Try it online!



                                      Explanation



                                      ẉ          Write the input followed by a linebreak
                                      ?Ḋ If the input is a single digit, then it's over
                                      | Otherwise
                                      ẹ Split the input into a list of digits
                                      × Multiply them together
                                      ↰ Recursive call with the result of the multiplication as input





                                      share|improve this answer









                                      $endgroup$













                                      • $begingroup$
                                        I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                        $endgroup$
                                        – Kroppeb
                                        Mar 21 at 19:33





















                                      3












                                      $begingroup$


                                      JavaScript (Babel Node), 46 bytes





                                      f=a=>a>9?[a,...f(eval([...a+''].join`*`))]:[a]


                                      Try it online!






                                      JavaScript (Babel Node), 44 bytes



                                      If the input can be taken as String





                                      f=a=>a>9?[a,...f(''+eval([...a].join`*`))]:a


                                      Try it online!






                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                        $endgroup$
                                        – Luis felipe De jesus Munoz
                                        Mar 21 at 15:12



















                                      3












                                      $begingroup$


                                      PowerShell, 64 59 bytes





                                      for($a="$args";9-lt$a){$a;$a="$(($a|% t*y)-join'*'|iex)"}$a


                                      Try it online!



                                      Iterative method. Takes input and stores it into $a, then enters a for loop so long as the length of $a is two or more (i.e., it's bigger than 9). Inside the loop we output $a and then recalculate it by converting it toCharArray, joining it together with *, and then iex (short for Invoke-Expression and similar to eval). Once we're out of the loop, we have a single digit left to print, so we place $a onto the pipeline again.



                                      -5 bytes thanks to KGlasier.






                                      share|improve this answer











                                      $endgroup$













                                      • $begingroup$
                                        You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                        $endgroup$
                                        – KGlasier
                                        Mar 21 at 16:22



















                                      3












                                      $begingroup$

                                      APL(NARS), 19 chars, 38 bytes



                                      {⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}


                                      test:



                                         f←{⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}
                                      f 23
                                      23
                                      6
                                      f 27648
                                      27648
                                      2688
                                      768
                                      336
                                      54
                                      20
                                      0





                                      share|improve this answer









                                      $endgroup$





















                                        3












                                        $begingroup$


                                        Charcoal, 13 bytes



                                        θW⊖Lθ«≔IΠθθ⸿θ


                                        Try it online! Link is to verbose version of code. Explanation:



                                        θ


                                        Print the input for the first time.



                                        W⊖Lθ«


                                        Repeat while the length of the input is not 1.



                                        ≔IΠθθ


                                        Replace the input with its digital product cast to string.



                                        ⸿θ


                                        Print the input on a new line.






                                        share|improve this answer









                                        $endgroup$





















                                          3












                                          $begingroup$


                                          C (gcc), 58 bytes





                                          f(n,t){for(;n=printf("%dn",t=n)>2;)for(;n*=t%10,t/=10;);}


                                          Try it online!



                                          Iterative approach turns out to be 1 byte shorter.



                                          f(n,t){
                                          for(;n=printf("%dn",t=n) //print and update current number
                                          >2;) //until only one digit is printed
                                          for(;n*=t%10,t/=10;); //n*= product of digits of t (step)
                                          }





                                          C (gcc), 61 59 bytes (recursive)





                                          f(n){printf("%dn",n)>2&&f(p(n));}p(n){n=n?n%10*p(n/10):1;}


                                          Try it online!



                                          Recursion seems to be shorter than iteration for both print and step...






                                          share|improve this answer











                                          $endgroup$





















                                            2












                                            $begingroup$


                                            Retina, 24 bytes



                                            .+~(`

                                            .
                                            $&$*
                                            ^
                                            .+¶$$.(


                                            Try it online! Explanation:



                                            .+~(`


                                            Print the current value on its own line at the start of every loop until it stops changing and don't print the unchanged value twice. Evaluate the current value at the end of each loop.



                                            .
                                            $&$*


                                            Add a * after each digit.



                                            ^
                                            .+¶$$.(


                                            Finish turning the input into an expression that evaluates to the digital product.



                                            Just for the record, Retina can do this in one line (25 bytes):



                                            .+"¶"<~[".+¶$.("|'*]'*L`.





                                            share|improve this answer









                                            $endgroup$





















                                              2












                                              $begingroup$

                                              Java, 112 bytes



                                              "Lossy conversion" thanks Java for the extra ~15 bytes


                                              Obligatory stream abuse recursion answer



                                              long f(long n){System.out.println(n);return n<10?n:f((n+"").chars().mapToLong(i->i).reduce(1,(x,y)->x*(y-48)));}


                                              Try it online






                                              share|improve this answer









                                              $endgroup$













                                              • $begingroup$
                                                I'm pretty sure you only need to support int
                                                $endgroup$
                                                – Embodiment of Ignorance
                                                2 days ago










                                              • $begingroup$
                                                @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                $endgroup$
                                                – Benjamin Urquhart
                                                yesterday















                                              1 2
                                              next



                                              Your Answer





                                              StackExchange.ifUsing("editor", function () {
                                              return StackExchange.using("mathjaxEditing", function () {
                                              StackExchange.MarkdownEditor.creationCallbacks.add(function (editor, postfix) {
                                              StackExchange.mathjaxEditing.prepareWmdForMathJax(editor, postfix, [["\$", "\$"]]);
                                              });
                                              });
                                              }, "mathjax-editing");

                                              StackExchange.ifUsing("editor", function () {
                                              StackExchange.using("externalEditor", function () {
                                              StackExchange.using("snippets", function () {
                                              StackExchange.snippets.init();
                                              });
                                              });
                                              }, "code-snippets");

                                              StackExchange.ready(function() {
                                              var channelOptions = {
                                              tags: "".split(" "),
                                              id: "200"
                                              };
                                              initTagRenderer("".split(" "), "".split(" "), channelOptions);

                                              StackExchange.using("externalEditor", function() {
                                              // Have to fire editor after snippets, if snippets enabled
                                              if (StackExchange.settings.snippets.snippetsEnabled) {
                                              StackExchange.using("snippets", function() {
                                              createEditor();
                                              });
                                              }
                                              else {
                                              createEditor();
                                              }
                                              });

                                              function createEditor() {
                                              StackExchange.prepareEditor({
                                              heartbeatType: 'answer',
                                              autoActivateHeartbeat: false,
                                              convertImagesToLinks: false,
                                              noModals: true,
                                              showLowRepImageUploadWarning: true,
                                              reputationToPostImages: null,
                                              bindNavPrevention: true,
                                              postfix: "",
                                              imageUploader: {
                                              brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                                              contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                                              allowUrls: true
                                              },
                                              onDemand: true,
                                              discardSelector: ".discard-answer"
                                              ,immediatelyShowMarkdownHelp:true
                                              });


                                              }
                                              });














                                              draft saved

                                              draft discarded


















                                              StackExchange.ready(
                                              function () {
                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181958%2fmultiplicative-persistence%23new-answer', 'question_page');
                                              }
                                              );

                                              Post as a guest















                                              Required, but never shown

























                                              44 Answers
                                              44






                                              active

                                              oldest

                                              votes








                                              44 Answers
                                              44






                                              active

                                              oldest

                                              votes









                                              active

                                              oldest

                                              votes






                                              active

                                              oldest

                                              votes








                                              1 2
                                              next










                                              13












                                              $begingroup$

                                              TI-BASIC (TI-84), 30 32 bytes



                                              While Ans>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-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>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-X-1),X,0,log(Ans:End:Ans  ;full program

                                              While Ans>9 End ;loop until the product is one digit
                                              Disp Ans ;print the current number
                                              prod( ;get the product of
                                              seq( ;the list generated by
                                              10^(-X-1), ;consecutive powers of ten
                                              X, ;using X as the increment variable
                                              0, ;starting at 0
                                              log(Ans ;ending at the length of the current number
                                              ;(implicit increment by 1)
                                              Ans ;multiplied by the current number
                                              fPart( ;then taking the fractional part of each element
                                              10 ;multiplied by 10
                                              int( ;then truncating each element
                                              Ans ;output last step since it was skipped


                                              Visual Model:
                                              Ans starts off as 125673.

                                              This model only covers the logic behind multiplying the digits; everything else is easier to understand.



                                              seq(10^(-X-1),X,0,log(Ans  =>  seq(10^(-X-1),X,0,5.0992
                                              {.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(10^(-X-1),X,0,log(Ans => seq(10^(-X-1),X,0,3.1004
                                              {.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.






                                              share|improve this answer











                                              $endgroup$


















                                                13












                                                $begingroup$

                                                TI-BASIC (TI-84), 30 32 bytes



                                                While Ans>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-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>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-X-1),X,0,log(Ans:End:Ans  ;full program

                                                While Ans>9 End ;loop until the product is one digit
                                                Disp Ans ;print the current number
                                                prod( ;get the product of
                                                seq( ;the list generated by
                                                10^(-X-1), ;consecutive powers of ten
                                                X, ;using X as the increment variable
                                                0, ;starting at 0
                                                log(Ans ;ending at the length of the current number
                                                ;(implicit increment by 1)
                                                Ans ;multiplied by the current number
                                                fPart( ;then taking the fractional part of each element
                                                10 ;multiplied by 10
                                                int( ;then truncating each element
                                                Ans ;output last step since it was skipped


                                                Visual Model:
                                                Ans starts off as 125673.

                                                This model only covers the logic behind multiplying the digits; everything else is easier to understand.



                                                seq(10^(-X-1),X,0,log(Ans  =>  seq(10^(-X-1),X,0,5.0992
                                                {.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(10^(-X-1),X,0,log(Ans => seq(10^(-X-1),X,0,3.1004
                                                {.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.






                                                share|improve this answer











                                                $endgroup$
















                                                  13












                                                  13








                                                  13





                                                  $begingroup$

                                                  TI-BASIC (TI-84), 30 32 bytes



                                                  While Ans>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-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>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-X-1),X,0,log(Ans:End:Ans  ;full program

                                                  While Ans>9 End ;loop until the product is one digit
                                                  Disp Ans ;print the current number
                                                  prod( ;get the product of
                                                  seq( ;the list generated by
                                                  10^(-X-1), ;consecutive powers of ten
                                                  X, ;using X as the increment variable
                                                  0, ;starting at 0
                                                  log(Ans ;ending at the length of the current number
                                                  ;(implicit increment by 1)
                                                  Ans ;multiplied by the current number
                                                  fPart( ;then taking the fractional part of each element
                                                  10 ;multiplied by 10
                                                  int( ;then truncating each element
                                                  Ans ;output last step since it was skipped


                                                  Visual Model:
                                                  Ans starts off as 125673.

                                                  This model only covers the logic behind multiplying the digits; everything else is easier to understand.



                                                  seq(10^(-X-1),X,0,log(Ans  =>  seq(10^(-X-1),X,0,5.0992
                                                  {.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(10^(-X-1),X,0,log(Ans => seq(10^(-X-1),X,0,3.1004
                                                  {.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.






                                                  share|improve this answer











                                                  $endgroup$



                                                  TI-BASIC (TI-84), 30 32 bytes



                                                  While Ans>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-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>9:Disp Ans:prod(int(10fPart(Ansseq(10^(-X-1),X,0,log(Ans:End:Ans  ;full program

                                                  While Ans>9 End ;loop until the product is one digit
                                                  Disp Ans ;print the current number
                                                  prod( ;get the product of
                                                  seq( ;the list generated by
                                                  10^(-X-1), ;consecutive powers of ten
                                                  X, ;using X as the increment variable
                                                  0, ;starting at 0
                                                  log(Ans ;ending at the length of the current number
                                                  ;(implicit increment by 1)
                                                  Ans ;multiplied by the current number
                                                  fPart( ;then taking the fractional part of each element
                                                  10 ;multiplied by 10
                                                  int( ;then truncating each element
                                                  Ans ;output last step since it was skipped


                                                  Visual Model:
                                                  Ans starts off as 125673.

                                                  This model only covers the logic behind multiplying the digits; everything else is easier to understand.



                                                  seq(10^(-X-1),X,0,log(Ans  =>  seq(10^(-X-1),X,0,5.0992
                                                  {.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(10^(-X-1),X,0,log(Ans => seq(10^(-X-1),X,0,3.1004
                                                  {.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.







                                                  share|improve this answer














                                                  share|improve this answer



                                                  share|improve this answer








                                                  edited 23 hours ago

























                                                  answered Mar 21 at 16:22









                                                  TauTau

                                                  626211




                                                  626211























                                                      11












                                                      $begingroup$


                                                      K (ngn/k), 9 bytes



                                                      {*/.'$x}


                                                      Try it online!



                                                      { } keep applying the function in curly braces until the sequence converges



                                                      $x format the argument as a string (list of characters)



                                                      .' evaluate each (other dialects of k require a colon, .:')



                                                      */ times over, i.e. product






                                                      share|improve this answer











                                                      $endgroup$


















                                                        11












                                                        $begingroup$


                                                        K (ngn/k), 9 bytes



                                                        {*/.'$x}


                                                        Try it online!



                                                        { } keep applying the function in curly braces until the sequence converges



                                                        $x format the argument as a string (list of characters)



                                                        .' evaluate each (other dialects of k require a colon, .:')



                                                        */ times over, i.e. product






                                                        share|improve this answer











                                                        $endgroup$
















                                                          11












                                                          11








                                                          11





                                                          $begingroup$


                                                          K (ngn/k), 9 bytes



                                                          {*/.'$x}


                                                          Try it online!



                                                          { } keep applying the function in curly braces until the sequence converges



                                                          $x format the argument as a string (list of characters)



                                                          .' evaluate each (other dialects of k require a colon, .:')



                                                          */ times over, i.e. product






                                                          share|improve this answer











                                                          $endgroup$




                                                          K (ngn/k), 9 bytes



                                                          {*/.'$x}


                                                          Try it online!



                                                          { } keep applying the function in curly braces until the sequence converges



                                                          $x format the argument as a string (list of characters)



                                                          .' evaluate each (other dialects of k require a colon, .:')



                                                          */ times over, i.e. product







                                                          share|improve this answer














                                                          share|improve this answer



                                                          share|improve this answer








                                                          edited 2 days ago

























                                                          answered Mar 21 at 15:18









                                                          ngnngn

                                                          7,29112560




                                                          7,29112560























                                                              8












                                                              $begingroup$


                                                              dzaima/APL, 14 11 bytes



                                                              ∪{×/⍎¨⍕⍵}⍡≡


                                                              Try it online!






                                                              share|improve this answer











                                                              $endgroup$


















                                                                8












                                                                $begingroup$


                                                                dzaima/APL, 14 11 bytes



                                                                ∪{×/⍎¨⍕⍵}⍡≡


                                                                Try it online!






                                                                share|improve this answer











                                                                $endgroup$
















                                                                  8












                                                                  8








                                                                  8





                                                                  $begingroup$


                                                                  dzaima/APL, 14 11 bytes



                                                                  ∪{×/⍎¨⍕⍵}⍡≡


                                                                  Try it online!






                                                                  share|improve this answer











                                                                  $endgroup$




                                                                  dzaima/APL, 14 11 bytes



                                                                  ∪{×/⍎¨⍕⍵}⍡≡


                                                                  Try it online!







                                                                  share|improve this answer














                                                                  share|improve this answer



                                                                  share|improve this answer








                                                                  edited Mar 21 at 19:10

























                                                                  answered Mar 21 at 14:37









                                                                  dzaimadzaima

                                                                  15.8k22059




                                                                  15.8k22059























                                                                      8












                                                                      $begingroup$


                                                                      R, 59 bytes





                                                                      n=scan();while(print(n)>9)n=prod(n%/%10^(nchar(n):1-1)%%10)


                                                                      Try it online!



                                                                      Since print invisibly returns its input, we can use print(n) inside the while loop to simulate a do-while loop. This is inspired by one of my tips for golfing in R.



                                                                      The header helps prevent large numbers from being printed in scientific notation.






                                                                      share|improve this answer











                                                                      $endgroup$


















                                                                        8












                                                                        $begingroup$


                                                                        R, 59 bytes





                                                                        n=scan();while(print(n)>9)n=prod(n%/%10^(nchar(n):1-1)%%10)


                                                                        Try it online!



                                                                        Since print invisibly returns its input, we can use print(n) inside the while loop to simulate a do-while loop. This is inspired by one of my tips for golfing in R.



                                                                        The header helps prevent large numbers from being printed in scientific notation.






                                                                        share|improve this answer











                                                                        $endgroup$
















                                                                          8












                                                                          8








                                                                          8





                                                                          $begingroup$


                                                                          R, 59 bytes





                                                                          n=scan();while(print(n)>9)n=prod(n%/%10^(nchar(n):1-1)%%10)


                                                                          Try it online!



                                                                          Since print invisibly returns its input, we can use print(n) inside the while loop to simulate a do-while loop. This is inspired by one of my tips for golfing in R.



                                                                          The header helps prevent large numbers from being printed in scientific notation.






                                                                          share|improve this answer











                                                                          $endgroup$




                                                                          R, 59 bytes





                                                                          n=scan();while(print(n)>9)n=prod(n%/%10^(nchar(n):1-1)%%10)


                                                                          Try it online!



                                                                          Since print invisibly returns its input, we can use print(n) inside the while loop to simulate a do-while loop. This is inspired by one of my tips for golfing in R.



                                                                          The header helps prevent large numbers from being printed in scientific notation.







                                                                          share|improve this answer














                                                                          share|improve this answer



                                                                          share|improve this answer








                                                                          edited Mar 21 at 20:08

























                                                                          answered Mar 21 at 14:50









                                                                          GiuseppeGiuseppe

                                                                          17.1k31152




                                                                          17.1k31152























                                                                              8












                                                                              $begingroup$


                                                                              05AB1E, 7 4 bytes



                                                                              Δ=SP


                                                                              Try it online or verify all test cases.



                                                                              Explanation:





                                                                              Δ     # Loop until the number no longer changes:
                                                                              = # Print the number with trailing newline (without popping the number itself)
                                                                              # (which will be the implicit input in the first iteration)
                                                                              SP # Convert the number to a list of digits, and calculate its product





                                                                              share|improve this answer











                                                                              $endgroup$


















                                                                                8












                                                                                $begingroup$


                                                                                05AB1E, 7 4 bytes



                                                                                Δ=SP


                                                                                Try it online or verify all test cases.



                                                                                Explanation:





                                                                                Δ     # Loop until the number no longer changes:
                                                                                = # Print the number with trailing newline (without popping the number itself)
                                                                                # (which will be the implicit input in the first iteration)
                                                                                SP # Convert the number to a list of digits, and calculate its product





                                                                                share|improve this answer











                                                                                $endgroup$
















                                                                                  8












                                                                                  8








                                                                                  8





                                                                                  $begingroup$


                                                                                  05AB1E, 7 4 bytes



                                                                                  Δ=SP


                                                                                  Try it online or verify all test cases.



                                                                                  Explanation:





                                                                                  Δ     # Loop until the number no longer changes:
                                                                                  = # Print the number with trailing newline (without popping the number itself)
                                                                                  # (which will be the implicit input in the first iteration)
                                                                                  SP # Convert the number to a list of digits, and calculate its product





                                                                                  share|improve this answer











                                                                                  $endgroup$




                                                                                  05AB1E, 7 4 bytes



                                                                                  Δ=SP


                                                                                  Try it online or verify all test cases.



                                                                                  Explanation:





                                                                                  Δ     # Loop until the number no longer changes:
                                                                                  = # Print the number with trailing newline (without popping the number itself)
                                                                                  # (which will be the implicit input in the first iteration)
                                                                                  SP # Convert the number to a list of digits, and calculate its product






                                                                                  share|improve this answer














                                                                                  share|improve this answer



                                                                                  share|improve this answer








                                                                                  edited 2 days ago

























                                                                                  answered Mar 21 at 14:30









                                                                                  Kevin CruijssenKevin Cruijssen

                                                                                  41.3k567213




                                                                                  41.3k567213























                                                                                      7












                                                                                      $begingroup$


                                                                                      Perl 6, 23 bytes





                                                                                      {$_,{[*] .comb}…10>*}


                                                                                      Try it online!






                                                                                      share|improve this answer









                                                                                      $endgroup$


















                                                                                        7












                                                                                        $begingroup$


                                                                                        Perl 6, 23 bytes





                                                                                        {$_,{[*] .comb}…10>*}


                                                                                        Try it online!






                                                                                        share|improve this answer









                                                                                        $endgroup$
















                                                                                          7












                                                                                          7








                                                                                          7





                                                                                          $begingroup$


                                                                                          Perl 6, 23 bytes





                                                                                          {$_,{[*] .comb}…10>*}


                                                                                          Try it online!






                                                                                          share|improve this answer









                                                                                          $endgroup$




                                                                                          Perl 6, 23 bytes





                                                                                          {$_,{[*] .comb}…10>*}


                                                                                          Try it online!







                                                                                          share|improve this answer












                                                                                          share|improve this answer



                                                                                          share|improve this answer










                                                                                          answered Mar 21 at 15:50









                                                                                          GrimyGrimy

                                                                                          2,5711019




                                                                                          2,5711019























                                                                                              7












                                                                                              $begingroup$


                                                                                              Python 2,  46  43 bytes





                                                                                              -3 thanks to xnor (chained comparison)



                                                                                              def f(n):print n;n>9>f(eval('*'.join(`n`)))


                                                                                              Try it online!






                                                                                              share|improve this answer











                                                                                              $endgroup$













                                                                                              • $begingroup$
                                                                                                You can do > in place of and.
                                                                                                $endgroup$
                                                                                                – xnor
                                                                                                2 days ago










                                                                                              • $begingroup$
                                                                                                @xnor thanks, easy to forget that will work.
                                                                                                $endgroup$
                                                                                                – Jonathan Allan
                                                                                                2 days ago
















                                                                                              7












                                                                                              $begingroup$


                                                                                              Python 2,  46  43 bytes





                                                                                              -3 thanks to xnor (chained comparison)



                                                                                              def f(n):print n;n>9>f(eval('*'.join(`n`)))


                                                                                              Try it online!






                                                                                              share|improve this answer











                                                                                              $endgroup$













                                                                                              • $begingroup$
                                                                                                You can do > in place of and.
                                                                                                $endgroup$
                                                                                                – xnor
                                                                                                2 days ago










                                                                                              • $begingroup$
                                                                                                @xnor thanks, easy to forget that will work.
                                                                                                $endgroup$
                                                                                                – Jonathan Allan
                                                                                                2 days ago














                                                                                              7












                                                                                              7








                                                                                              7





                                                                                              $begingroup$


                                                                                              Python 2,  46  43 bytes





                                                                                              -3 thanks to xnor (chained comparison)



                                                                                              def f(n):print n;n>9>f(eval('*'.join(`n`)))


                                                                                              Try it online!






                                                                                              share|improve this answer











                                                                                              $endgroup$




                                                                                              Python 2,  46  43 bytes





                                                                                              -3 thanks to xnor (chained comparison)



                                                                                              def f(n):print n;n>9>f(eval('*'.join(`n`)))


                                                                                              Try it online!







                                                                                              share|improve this answer














                                                                                              share|improve this answer



                                                                                              share|improve this answer








                                                                                              edited 2 days ago

























                                                                                              answered Mar 21 at 17:33









                                                                                              Jonathan AllanJonathan Allan

                                                                                              53.4k535172




                                                                                              53.4k535172












                                                                                              • $begingroup$
                                                                                                You can do > in place of and.
                                                                                                $endgroup$
                                                                                                – xnor
                                                                                                2 days ago










                                                                                              • $begingroup$
                                                                                                @xnor thanks, easy to forget that will work.
                                                                                                $endgroup$
                                                                                                – Jonathan Allan
                                                                                                2 days ago


















                                                                                              • $begingroup$
                                                                                                You can do > in place of and.
                                                                                                $endgroup$
                                                                                                – xnor
                                                                                                2 days ago










                                                                                              • $begingroup$
                                                                                                @xnor thanks, easy to forget that will work.
                                                                                                $endgroup$
                                                                                                – Jonathan Allan
                                                                                                2 days ago
















                                                                                              $begingroup$
                                                                                              You can do > in place of and.
                                                                                              $endgroup$
                                                                                              – xnor
                                                                                              2 days ago




                                                                                              $begingroup$
                                                                                              You can do > in place of and.
                                                                                              $endgroup$
                                                                                              – xnor
                                                                                              2 days ago












                                                                                              $begingroup$
                                                                                              @xnor thanks, easy to forget that will work.
                                                                                              $endgroup$
                                                                                              – Jonathan Allan
                                                                                              2 days ago




                                                                                              $begingroup$
                                                                                              @xnor thanks, easy to forget that will work.
                                                                                              $endgroup$
                                                                                              – Jonathan Allan
                                                                                              2 days ago











                                                                                              6












                                                                                              $begingroup$


                                                                                              Wolfram Language (Mathematica), 47 bytes



                                                                                              Most@FixedPointList[Times@@IntegerDigits@#&,#]&


                                                                                              Try it online!






                                                                                              share|improve this answer









                                                                                              $endgroup$


















                                                                                                6












                                                                                                $begingroup$


                                                                                                Wolfram Language (Mathematica), 47 bytes



                                                                                                Most@FixedPointList[Times@@IntegerDigits@#&,#]&


                                                                                                Try it online!






                                                                                                share|improve this answer









                                                                                                $endgroup$
















                                                                                                  6












                                                                                                  6








                                                                                                  6





                                                                                                  $begingroup$


                                                                                                  Wolfram Language (Mathematica), 47 bytes



                                                                                                  Most@FixedPointList[Times@@IntegerDigits@#&,#]&


                                                                                                  Try it online!






                                                                                                  share|improve this answer









                                                                                                  $endgroup$




                                                                                                  Wolfram Language (Mathematica), 47 bytes



                                                                                                  Most@FixedPointList[Times@@IntegerDigits@#&,#]&


                                                                                                  Try it online!







                                                                                                  share|improve this answer












                                                                                                  share|improve this answer



                                                                                                  share|improve this answer










                                                                                                  answered Mar 21 at 14:25









                                                                                                  J42161217J42161217

                                                                                                  13.5k21252




                                                                                                  13.5k21252























                                                                                                      6












                                                                                                      $begingroup$


                                                                                                      Wolfram Language (Mathematica), 45 bytes



                                                                                                      #//.x_/;x>9:>Times@@IntegerDigits@x&&Print@x&


                                                                                                      Try it online!






                                                                                                      share|improve this answer









                                                                                                      $endgroup$


















                                                                                                        6












                                                                                                        $begingroup$


                                                                                                        Wolfram Language (Mathematica), 45 bytes



                                                                                                        #//.x_/;x>9:>Times@@IntegerDigits@x&&Print@x&


                                                                                                        Try it online!






                                                                                                        share|improve this answer









                                                                                                        $endgroup$
















                                                                                                          6












                                                                                                          6








                                                                                                          6





                                                                                                          $begingroup$


                                                                                                          Wolfram Language (Mathematica), 45 bytes



                                                                                                          #//.x_/;x>9:>Times@@IntegerDigits@x&&Print@x&


                                                                                                          Try it online!






                                                                                                          share|improve this answer









                                                                                                          $endgroup$




                                                                                                          Wolfram Language (Mathematica), 45 bytes



                                                                                                          #//.x_/;x>9:>Times@@IntegerDigits@x&&Print@x&


                                                                                                          Try it online!







                                                                                                          share|improve this answer












                                                                                                          share|improve this answer



                                                                                                          share|improve this answer










                                                                                                          answered Mar 21 at 15:18









                                                                                                          J42161217J42161217

                                                                                                          13.5k21252




                                                                                                          13.5k21252























                                                                                                              6












                                                                                                              $begingroup$


                                                                                                              Jelly, 4 bytes



                                                                                                              DP$Ƭ


                                                                                                              Try it online!



                                                                                                              Explanation



                                                                                                              D    | convert to decimal digits
                                                                                                              P | take the product
                                                                                                              $ | previous two links as a monad
                                                                                                              Ƭ | loop until no change, collecting all intermediate results


                                                                                                              As a bonus, here's a TIO which will find the numbers with the largest number of steps for a given range of numbers of digits. It scales well even on TIO.






                                                                                                              share|improve this answer











                                                                                                              $endgroup$


















                                                                                                                6












                                                                                                                $begingroup$


                                                                                                                Jelly, 4 bytes



                                                                                                                DP$Ƭ


                                                                                                                Try it online!



                                                                                                                Explanation



                                                                                                                D    | convert to decimal digits
                                                                                                                P | take the product
                                                                                                                $ | previous two links as a monad
                                                                                                                Ƭ | loop until no change, collecting all intermediate results


                                                                                                                As a bonus, here's a TIO which will find the numbers with the largest number of steps for a given range of numbers of digits. It scales well even on TIO.






                                                                                                                share|improve this answer











                                                                                                                $endgroup$
















                                                                                                                  6












                                                                                                                  6








                                                                                                                  6





                                                                                                                  $begingroup$


                                                                                                                  Jelly, 4 bytes



                                                                                                                  DP$Ƭ


                                                                                                                  Try it online!



                                                                                                                  Explanation



                                                                                                                  D    | convert to decimal digits
                                                                                                                  P | take the product
                                                                                                                  $ | previous two links as a monad
                                                                                                                  Ƭ | loop until no change, collecting all intermediate results


                                                                                                                  As a bonus, here's a TIO which will find the numbers with the largest number of steps for a given range of numbers of digits. It scales well even on TIO.






                                                                                                                  share|improve this answer











                                                                                                                  $endgroup$




                                                                                                                  Jelly, 4 bytes



                                                                                                                  DP$Ƭ


                                                                                                                  Try it online!



                                                                                                                  Explanation



                                                                                                                  D    | convert to decimal digits
                                                                                                                  P | take the product
                                                                                                                  $ | previous two links as a monad
                                                                                                                  Ƭ | loop until no change, collecting all intermediate results


                                                                                                                  As a bonus, here's a TIO which will find the numbers with the largest number of steps for a given range of numbers of digits. It scales well even on TIO.







                                                                                                                  share|improve this answer














                                                                                                                  share|improve this answer



                                                                                                                  share|improve this answer








                                                                                                                  edited Mar 21 at 23:30

























                                                                                                                  answered Mar 21 at 15:08









                                                                                                                  Nick KennedyNick Kennedy

                                                                                                                  92147




                                                                                                                  92147























                                                                                                                      5












                                                                                                                      $begingroup$


                                                                                                                      Julia 0.7, 36 bytes





                                                                                                                      f(n)=n>9?[n,f(prod(digits(n)))...]:n


                                                                                                                      Try it online!






                                                                                                                      share|improve this answer









                                                                                                                      $endgroup$


















                                                                                                                        5












                                                                                                                        $begingroup$


                                                                                                                        Julia 0.7, 36 bytes





                                                                                                                        f(n)=n>9?[n,f(prod(digits(n)))...]:n


                                                                                                                        Try it online!






                                                                                                                        share|improve this answer









                                                                                                                        $endgroup$
















                                                                                                                          5












                                                                                                                          5








                                                                                                                          5





                                                                                                                          $begingroup$


                                                                                                                          Julia 0.7, 36 bytes





                                                                                                                          f(n)=n>9?[n,f(prod(digits(n)))...]:n


                                                                                                                          Try it online!






                                                                                                                          share|improve this answer









                                                                                                                          $endgroup$




                                                                                                                          Julia 0.7, 36 bytes





                                                                                                                          f(n)=n>9?[n,f(prod(digits(n)))...]:n


                                                                                                                          Try it online!







                                                                                                                          share|improve this answer












                                                                                                                          share|improve this answer



                                                                                                                          share|improve this answer










                                                                                                                          answered Mar 21 at 14:44









                                                                                                                          Kirill L.Kirill L.

                                                                                                                          5,6831525




                                                                                                                          5,6831525























                                                                                                                              5












                                                                                                                              $begingroup$


                                                                                                                              PowerShell, 54 bytes





                                                                                                                              for($a=$args;$a-gt9){$a;$a=("$a"|% t*y)-join"*"|iex}$a


                                                                                                                              Try it online!





                                                                                                                              Iterative method that first writes the input argument, then converts it into a string and pipes it into a character array. This array is joined by a single asterisks, and executed as a command with the invoke expression alias. Since this writes Starting number down to the last number greater than 0, (20, in the given test scenario), I add a final $a to the end to output.






                                                                                                                              share|improve this answer











                                                                                                                              $endgroup$


















                                                                                                                                5












                                                                                                                                $begingroup$


                                                                                                                                PowerShell, 54 bytes





                                                                                                                                for($a=$args;$a-gt9){$a;$a=("$a"|% t*y)-join"*"|iex}$a


                                                                                                                                Try it online!





                                                                                                                                Iterative method that first writes the input argument, then converts it into a string and pipes it into a character array. This array is joined by a single asterisks, and executed as a command with the invoke expression alias. Since this writes Starting number down to the last number greater than 0, (20, in the given test scenario), I add a final $a to the end to output.






                                                                                                                                share|improve this answer











                                                                                                                                $endgroup$
















                                                                                                                                  5












                                                                                                                                  5








                                                                                                                                  5





                                                                                                                                  $begingroup$


                                                                                                                                  PowerShell, 54 bytes





                                                                                                                                  for($a=$args;$a-gt9){$a;$a=("$a"|% t*y)-join"*"|iex}$a


                                                                                                                                  Try it online!





                                                                                                                                  Iterative method that first writes the input argument, then converts it into a string and pipes it into a character array. This array is joined by a single asterisks, and executed as a command with the invoke expression alias. Since this writes Starting number down to the last number greater than 0, (20, in the given test scenario), I add a final $a to the end to output.






                                                                                                                                  share|improve this answer











                                                                                                                                  $endgroup$




                                                                                                                                  PowerShell, 54 bytes





                                                                                                                                  for($a=$args;$a-gt9){$a;$a=("$a"|% t*y)-join"*"|iex}$a


                                                                                                                                  Try it online!





                                                                                                                                  Iterative method that first writes the input argument, then converts it into a string and pipes it into a character array. This array is joined by a single asterisks, and executed as a command with the invoke expression alias. Since this writes Starting number down to the last number greater than 0, (20, in the given test scenario), I add a final $a to the end to output.







                                                                                                                                  share|improve this answer














                                                                                                                                  share|improve this answer



                                                                                                                                  share|improve this answer








                                                                                                                                  edited Mar 21 at 16:12

























                                                                                                                                  answered Mar 21 at 15:53









                                                                                                                                  KGlasierKGlasier

                                                                                                                                  1916




                                                                                                                                  1916























                                                                                                                                      5












                                                                                                                                      $begingroup$


                                                                                                                                      C# (Visual C# Interactive Compiler), 79 74 68 bytes





                                                                                                                                      void f(int a){Print(a);if(a>9)f((a+"").Aggregate(1,(j,k)=>k%48*j));}


                                                                                                                                      I try to stay away from recursion in C# due to how long the method declaration is, but in this case it saves compared to a loop.



                                                                                                                                      Try it online!






                                                                                                                                      share|improve this answer











                                                                                                                                      $endgroup$


















                                                                                                                                        5












                                                                                                                                        $begingroup$


                                                                                                                                        C# (Visual C# Interactive Compiler), 79 74 68 bytes





                                                                                                                                        void f(int a){Print(a);if(a>9)f((a+"").Aggregate(1,(j,k)=>k%48*j));}


                                                                                                                                        I try to stay away from recursion in C# due to how long the method declaration is, but in this case it saves compared to a loop.



                                                                                                                                        Try it online!






                                                                                                                                        share|improve this answer











                                                                                                                                        $endgroup$
















                                                                                                                                          5












                                                                                                                                          5








                                                                                                                                          5





                                                                                                                                          $begingroup$


                                                                                                                                          C# (Visual C# Interactive Compiler), 79 74 68 bytes





                                                                                                                                          void f(int a){Print(a);if(a>9)f((a+"").Aggregate(1,(j,k)=>k%48*j));}


                                                                                                                                          I try to stay away from recursion in C# due to how long the method declaration is, but in this case it saves compared to a loop.



                                                                                                                                          Try it online!






                                                                                                                                          share|improve this answer











                                                                                                                                          $endgroup$




                                                                                                                                          C# (Visual C# Interactive Compiler), 79 74 68 bytes





                                                                                                                                          void f(int a){Print(a);if(a>9)f((a+"").Aggregate(1,(j,k)=>k%48*j));}


                                                                                                                                          I try to stay away from recursion in C# due to how long the method declaration is, but in this case it saves compared to a loop.



                                                                                                                                          Try it online!







                                                                                                                                          share|improve this answer














                                                                                                                                          share|improve this answer



                                                                                                                                          share|improve this answer








                                                                                                                                          edited Mar 21 at 16:32

























                                                                                                                                          answered Mar 21 at 15:30









                                                                                                                                          Embodiment of IgnoranceEmbodiment of Ignorance

                                                                                                                                          2,138125




                                                                                                                                          2,138125























                                                                                                                                              5












                                                                                                                                              $begingroup$


                                                                                                                                              Python 2, 61 62 59 bytes





                                                                                                                                              def f(n):print n;n>9and f(reduce(int.__mul__,map(int,`n`)))


                                                                                                                                              Try it online!



                                                                                                                                              -3 bytes, thanks to Jonathan Allan






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                                                                                                                                                $endgroup$
                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                Mar 21 at 15:40










                                                                                                                                              • $begingroup$
                                                                                                                                                int.__mul__ is three bytes less than lambda a,b:a*b
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 17:17










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanAllan Thanks! I knew there had to be something like that
                                                                                                                                                $endgroup$
                                                                                                                                                – TFeld
                                                                                                                                                Mar 21 at 19:05










                                                                                                                                              • $begingroup$
                                                                                                                                                Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                                                                                                                                                $endgroup$
                                                                                                                                                – mypetlion
                                                                                                                                                Mar 21 at 20:34












                                                                                                                                              • $begingroup$
                                                                                                                                                @mypetlion ...I already did that in another post.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 20:52
















                                                                                                                                              5












                                                                                                                                              $begingroup$


                                                                                                                                              Python 2, 61 62 59 bytes





                                                                                                                                              def f(n):print n;n>9and f(reduce(int.__mul__,map(int,`n`)))


                                                                                                                                              Try it online!



                                                                                                                                              -3 bytes, thanks to Jonathan Allan






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                                                                                                                                                $endgroup$
                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                Mar 21 at 15:40










                                                                                                                                              • $begingroup$
                                                                                                                                                int.__mul__ is three bytes less than lambda a,b:a*b
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 17:17










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanAllan Thanks! I knew there had to be something like that
                                                                                                                                                $endgroup$
                                                                                                                                                – TFeld
                                                                                                                                                Mar 21 at 19:05










                                                                                                                                              • $begingroup$
                                                                                                                                                Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                                                                                                                                                $endgroup$
                                                                                                                                                – mypetlion
                                                                                                                                                Mar 21 at 20:34












                                                                                                                                              • $begingroup$
                                                                                                                                                @mypetlion ...I already did that in another post.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 20:52














                                                                                                                                              5












                                                                                                                                              5








                                                                                                                                              5





                                                                                                                                              $begingroup$


                                                                                                                                              Python 2, 61 62 59 bytes





                                                                                                                                              def f(n):print n;n>9and f(reduce(int.__mul__,map(int,`n`)))


                                                                                                                                              Try it online!



                                                                                                                                              -3 bytes, thanks to Jonathan Allan






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$




                                                                                                                                              Python 2, 61 62 59 bytes





                                                                                                                                              def f(n):print n;n>9and f(reduce(int.__mul__,map(int,`n`)))


                                                                                                                                              Try it online!



                                                                                                                                              -3 bytes, thanks to Jonathan Allan







                                                                                                                                              share|improve this answer














                                                                                                                                              share|improve this answer



                                                                                                                                              share|improve this answer








                                                                                                                                              edited Mar 21 at 19:07

























                                                                                                                                              answered Mar 21 at 15:39









                                                                                                                                              TFeldTFeld

                                                                                                                                              15.9k21449




                                                                                                                                              15.9k21449












                                                                                                                                              • $begingroup$
                                                                                                                                                Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                                                                                                                                                $endgroup$
                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                Mar 21 at 15:40










                                                                                                                                              • $begingroup$
                                                                                                                                                int.__mul__ is three bytes less than lambda a,b:a*b
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 17:17










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanAllan Thanks! I knew there had to be something like that
                                                                                                                                                $endgroup$
                                                                                                                                                – TFeld
                                                                                                                                                Mar 21 at 19:05










                                                                                                                                              • $begingroup$
                                                                                                                                                Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                                                                                                                                                $endgroup$
                                                                                                                                                – mypetlion
                                                                                                                                                Mar 21 at 20:34












                                                                                                                                              • $begingroup$
                                                                                                                                                @mypetlion ...I already did that in another post.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 20:52


















                                                                                                                                              • $begingroup$
                                                                                                                                                Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                                                                                                                                                $endgroup$
                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                Mar 21 at 15:40










                                                                                                                                              • $begingroup$
                                                                                                                                                int.__mul__ is three bytes less than lambda a,b:a*b
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 17:17










                                                                                                                                              • $begingroup$
                                                                                                                                                @JonathanAllan Thanks! I knew there had to be something like that
                                                                                                                                                $endgroup$
                                                                                                                                                – TFeld
                                                                                                                                                Mar 21 at 19:05










                                                                                                                                              • $begingroup$
                                                                                                                                                Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                                                                                                                                                $endgroup$
                                                                                                                                                – mypetlion
                                                                                                                                                Mar 21 at 20:34












                                                                                                                                              • $begingroup$
                                                                                                                                                @mypetlion ...I already did that in another post.
                                                                                                                                                $endgroup$
                                                                                                                                                – Jonathan Allan
                                                                                                                                                Mar 21 at 20:52
















                                                                                                                                              $begingroup$
                                                                                                                                              Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                                                                                                                                              $endgroup$
                                                                                                                                              – Embodiment of Ignorance
                                                                                                                                              Mar 21 at 15:40




                                                                                                                                              $begingroup$
                                                                                                                                              Doesn't work for inputs that don't end with a 0 on their last iteration, for example 23
                                                                                                                                              $endgroup$
                                                                                                                                              – Embodiment of Ignorance
                                                                                                                                              Mar 21 at 15:40












                                                                                                                                              $begingroup$
                                                                                                                                              int.__mul__ is three bytes less than lambda a,b:a*b
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Allan
                                                                                                                                              Mar 21 at 17:17




                                                                                                                                              $begingroup$
                                                                                                                                              int.__mul__ is three bytes less than lambda a,b:a*b
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Allan
                                                                                                                                              Mar 21 at 17:17












                                                                                                                                              $begingroup$
                                                                                                                                              @JonathanAllan Thanks! I knew there had to be something like that
                                                                                                                                              $endgroup$
                                                                                                                                              – TFeld
                                                                                                                                              Mar 21 at 19:05




                                                                                                                                              $begingroup$
                                                                                                                                              @JonathanAllan Thanks! I knew there had to be something like that
                                                                                                                                              $endgroup$
                                                                                                                                              – TFeld
                                                                                                                                              Mar 21 at 19:05












                                                                                                                                              $begingroup$
                                                                                                                                              Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                                                                                                                                              $endgroup$
                                                                                                                                              – mypetlion
                                                                                                                                              Mar 21 at 20:34






                                                                                                                                              $begingroup$
                                                                                                                                              Change f(reduce(int.__mul__,map(int,`n`))) to f(eval('*'.join(`n`))) to save 13 bytes.
                                                                                                                                              $endgroup$
                                                                                                                                              – mypetlion
                                                                                                                                              Mar 21 at 20:34














                                                                                                                                              $begingroup$
                                                                                                                                              @mypetlion ...I already did that in another post.
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Allan
                                                                                                                                              Mar 21 at 20:52




                                                                                                                                              $begingroup$
                                                                                                                                              @mypetlion ...I already did that in another post.
                                                                                                                                              $endgroup$
                                                                                                                                              – Jonathan Allan
                                                                                                                                              Mar 21 at 20:52











                                                                                                                                              5












                                                                                                                                              $begingroup$

                                                                                                                                              perl 5 (-n -M5.01), 32 30 25 bytes



                                                                                                                                              say$_=eval;s/B/*/g&&redo


                                                                                                                                              25 bytes



                                                                                                                                              30 bytes



                                                                                                                                              32 bytes






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                You should mention that this uses -lpF//
                                                                                                                                                $endgroup$
                                                                                                                                                – Grimy
                                                                                                                                                2 days ago






                                                                                                                                              • 1




                                                                                                                                                $begingroup$
                                                                                                                                                @Grimy i could save 2 bytes without using -lpF//, updating
                                                                                                                                                $endgroup$
                                                                                                                                                – Nahuel Fouilleul
                                                                                                                                                2 days ago
















                                                                                                                                              5












                                                                                                                                              $begingroup$

                                                                                                                                              perl 5 (-n -M5.01), 32 30 25 bytes



                                                                                                                                              say$_=eval;s/B/*/g&&redo


                                                                                                                                              25 bytes



                                                                                                                                              30 bytes



                                                                                                                                              32 bytes






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                You should mention that this uses -lpF//
                                                                                                                                                $endgroup$
                                                                                                                                                – Grimy
                                                                                                                                                2 days ago






                                                                                                                                              • 1




                                                                                                                                                $begingroup$
                                                                                                                                                @Grimy i could save 2 bytes without using -lpF//, updating
                                                                                                                                                $endgroup$
                                                                                                                                                – Nahuel Fouilleul
                                                                                                                                                2 days ago














                                                                                                                                              5












                                                                                                                                              5








                                                                                                                                              5





                                                                                                                                              $begingroup$

                                                                                                                                              perl 5 (-n -M5.01), 32 30 25 bytes



                                                                                                                                              say$_=eval;s/B/*/g&&redo


                                                                                                                                              25 bytes



                                                                                                                                              30 bytes



                                                                                                                                              32 bytes






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$



                                                                                                                                              perl 5 (-n -M5.01), 32 30 25 bytes



                                                                                                                                              say$_=eval;s/B/*/g&&redo


                                                                                                                                              25 bytes



                                                                                                                                              30 bytes



                                                                                                                                              32 bytes







                                                                                                                                              share|improve this answer














                                                                                                                                              share|improve this answer



                                                                                                                                              share|improve this answer








                                                                                                                                              edited 2 days ago

























                                                                                                                                              answered Mar 21 at 16:21









                                                                                                                                              Nahuel FouilleulNahuel Fouilleul

                                                                                                                                              2,905211




                                                                                                                                              2,905211












                                                                                                                                              • $begingroup$
                                                                                                                                                You should mention that this uses -lpF//
                                                                                                                                                $endgroup$
                                                                                                                                                – Grimy
                                                                                                                                                2 days ago






                                                                                                                                              • 1




                                                                                                                                                $begingroup$
                                                                                                                                                @Grimy i could save 2 bytes without using -lpF//, updating
                                                                                                                                                $endgroup$
                                                                                                                                                – Nahuel Fouilleul
                                                                                                                                                2 days ago


















                                                                                                                                              • $begingroup$
                                                                                                                                                You should mention that this uses -lpF//
                                                                                                                                                $endgroup$
                                                                                                                                                – Grimy
                                                                                                                                                2 days ago






                                                                                                                                              • 1




                                                                                                                                                $begingroup$
                                                                                                                                                @Grimy i could save 2 bytes without using -lpF//, updating
                                                                                                                                                $endgroup$
                                                                                                                                                – Nahuel Fouilleul
                                                                                                                                                2 days ago
















                                                                                                                                              $begingroup$
                                                                                                                                              You should mention that this uses -lpF//
                                                                                                                                              $endgroup$
                                                                                                                                              – Grimy
                                                                                                                                              2 days ago




                                                                                                                                              $begingroup$
                                                                                                                                              You should mention that this uses -lpF//
                                                                                                                                              $endgroup$
                                                                                                                                              – Grimy
                                                                                                                                              2 days ago




                                                                                                                                              1




                                                                                                                                              1




                                                                                                                                              $begingroup$
                                                                                                                                              @Grimy i could save 2 bytes without using -lpF//, updating
                                                                                                                                              $endgroup$
                                                                                                                                              – Nahuel Fouilleul
                                                                                                                                              2 days ago




                                                                                                                                              $begingroup$
                                                                                                                                              @Grimy i could save 2 bytes without using -lpF//, updating
                                                                                                                                              $endgroup$
                                                                                                                                              – Nahuel Fouilleul
                                                                                                                                              2 days ago











                                                                                                                                              5












                                                                                                                                              $begingroup$


                                                                                                                                              MathGolf, 9 10 bytes



                                                                                                                                              h(ôo▒ε*h(→


                                                                                                                                              Try it online!



                                                                                                                                              Now it correctly handles inputs that are single digits. Not perfect, but at least it is correct.



                                                                                                                                              Explanation



                                                                                                                                              h(            check length of input number and decrease by 1
                                                                                                                                              ö → while true with pop using the next 6 operators
                                                                                                                                              p print with newline
                                                                                                                                              ▒ split to list of chars/digits
                                                                                                                                              ε* reduce list by multiplication
                                                                                                                                              h( length of TOS without popping, subtracted by 1 (exits when len(TOS) == 1)





                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                The output for a single digit input should be one copy of the number - clarified in the comments
                                                                                                                                                $endgroup$
                                                                                                                                                – dzaima
                                                                                                                                                Mar 21 at 18:38










                                                                                                                                              • $begingroup$
                                                                                                                                                @dzaima I'll look into it, and update the answer when it's solved
                                                                                                                                                $endgroup$
                                                                                                                                                – maxb
                                                                                                                                                2 days ago
















                                                                                                                                              5












                                                                                                                                              $begingroup$


                                                                                                                                              MathGolf, 9 10 bytes



                                                                                                                                              h(ôo▒ε*h(→


                                                                                                                                              Try it online!



                                                                                                                                              Now it correctly handles inputs that are single digits. Not perfect, but at least it is correct.



                                                                                                                                              Explanation



                                                                                                                                              h(            check length of input number and decrease by 1
                                                                                                                                              ö → while true with pop using the next 6 operators
                                                                                                                                              p print with newline
                                                                                                                                              ▒ split to list of chars/digits
                                                                                                                                              ε* reduce list by multiplication
                                                                                                                                              h( length of TOS without popping, subtracted by 1 (exits when len(TOS) == 1)





                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$













                                                                                                                                              • $begingroup$
                                                                                                                                                The output for a single digit input should be one copy of the number - clarified in the comments
                                                                                                                                                $endgroup$
                                                                                                                                                – dzaima
                                                                                                                                                Mar 21 at 18:38










                                                                                                                                              • $begingroup$
                                                                                                                                                @dzaima I'll look into it, and update the answer when it's solved
                                                                                                                                                $endgroup$
                                                                                                                                                – maxb
                                                                                                                                                2 days ago














                                                                                                                                              5












                                                                                                                                              5








                                                                                                                                              5





                                                                                                                                              $begingroup$


                                                                                                                                              MathGolf, 9 10 bytes



                                                                                                                                              h(ôo▒ε*h(→


                                                                                                                                              Try it online!



                                                                                                                                              Now it correctly handles inputs that are single digits. Not perfect, but at least it is correct.



                                                                                                                                              Explanation



                                                                                                                                              h(            check length of input number and decrease by 1
                                                                                                                                              ö → while true with pop using the next 6 operators
                                                                                                                                              p print with newline
                                                                                                                                              ▒ split to list of chars/digits
                                                                                                                                              ε* reduce list by multiplication
                                                                                                                                              h( length of TOS without popping, subtracted by 1 (exits when len(TOS) == 1)





                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$




                                                                                                                                              MathGolf, 9 10 bytes



                                                                                                                                              h(ôo▒ε*h(→


                                                                                                                                              Try it online!



                                                                                                                                              Now it correctly handles inputs that are single digits. Not perfect, but at least it is correct.



                                                                                                                                              Explanation



                                                                                                                                              h(            check length of input number and decrease by 1
                                                                                                                                              ö → while true with pop using the next 6 operators
                                                                                                                                              p print with newline
                                                                                                                                              ▒ split to list of chars/digits
                                                                                                                                              ε* reduce list by multiplication
                                                                                                                                              h( length of TOS without popping, subtracted by 1 (exits when len(TOS) == 1)






                                                                                                                                              share|improve this answer














                                                                                                                                              share|improve this answer



                                                                                                                                              share|improve this answer








                                                                                                                                              edited 2 days ago









                                                                                                                                              Scott Milner

                                                                                                                                              1,676521




                                                                                                                                              1,676521










                                                                                                                                              answered Mar 21 at 15:12









                                                                                                                                              maxbmaxb

                                                                                                                                              3,30811232




                                                                                                                                              3,30811232












                                                                                                                                              • $begingroup$
                                                                                                                                                The output for a single digit input should be one copy of the number - clarified in the comments
                                                                                                                                                $endgroup$
                                                                                                                                                – dzaima
                                                                                                                                                Mar 21 at 18:38










                                                                                                                                              • $begingroup$
                                                                                                                                                @dzaima I'll look into it, and update the answer when it's solved
                                                                                                                                                $endgroup$
                                                                                                                                                – maxb
                                                                                                                                                2 days ago


















                                                                                                                                              • $begingroup$
                                                                                                                                                The output for a single digit input should be one copy of the number - clarified in the comments
                                                                                                                                                $endgroup$
                                                                                                                                                – dzaima
                                                                                                                                                Mar 21 at 18:38










                                                                                                                                              • $begingroup$
                                                                                                                                                @dzaima I'll look into it, and update the answer when it's solved
                                                                                                                                                $endgroup$
                                                                                                                                                – maxb
                                                                                                                                                2 days ago
















                                                                                                                                              $begingroup$
                                                                                                                                              The output for a single digit input should be one copy of the number - clarified in the comments
                                                                                                                                              $endgroup$
                                                                                                                                              – dzaima
                                                                                                                                              Mar 21 at 18:38




                                                                                                                                              $begingroup$
                                                                                                                                              The output for a single digit input should be one copy of the number - clarified in the comments
                                                                                                                                              $endgroup$
                                                                                                                                              – dzaima
                                                                                                                                              Mar 21 at 18:38












                                                                                                                                              $begingroup$
                                                                                                                                              @dzaima I'll look into it, and update the answer when it's solved
                                                                                                                                              $endgroup$
                                                                                                                                              – maxb
                                                                                                                                              2 days ago




                                                                                                                                              $begingroup$
                                                                                                                                              @dzaima I'll look into it, and update the answer when it's solved
                                                                                                                                              $endgroup$
                                                                                                                                              – maxb
                                                                                                                                              2 days ago











                                                                                                                                              4












                                                                                                                                              $begingroup$

                                                                                                                                              JavaScript (ES6), 45 bytes



                                                                                                                                              Returns an array of integers.





                                                                                                                                              f=n=>[n,...n>9?f(eval([...n+''].join`*`)):]


                                                                                                                                              Try it online!






                                                                                                                                              share|improve this answer











                                                                                                                                              $endgroup$


















                                                                                                                                                4












                                                                                                                                                $begingroup$

                                                                                                                                                JavaScript (ES6), 45 bytes



                                                                                                                                                Returns an array of integers.





                                                                                                                                                f=n=>[n,...n>9?f(eval([...n+''].join`*`)):]


                                                                                                                                                Try it online!






                                                                                                                                                share|improve this answer











                                                                                                                                                $endgroup$
















                                                                                                                                                  4












                                                                                                                                                  4








                                                                                                                                                  4





                                                                                                                                                  $begingroup$

                                                                                                                                                  JavaScript (ES6), 45 bytes



                                                                                                                                                  Returns an array of integers.





                                                                                                                                                  f=n=>[n,...n>9?f(eval([...n+''].join`*`)):]


                                                                                                                                                  Try it online!






                                                                                                                                                  share|improve this answer











                                                                                                                                                  $endgroup$



                                                                                                                                                  JavaScript (ES6), 45 bytes



                                                                                                                                                  Returns an array of integers.





                                                                                                                                                  f=n=>[n,...n>9?f(eval([...n+''].join`*`)):]


                                                                                                                                                  Try it online!







                                                                                                                                                  share|improve this answer














                                                                                                                                                  share|improve this answer



                                                                                                                                                  share|improve this answer








                                                                                                                                                  edited Mar 21 at 14:29

























                                                                                                                                                  answered Mar 21 at 14:24









                                                                                                                                                  ArnauldArnauld

                                                                                                                                                  79.6k796330




                                                                                                                                                  79.6k796330























                                                                                                                                                      4












                                                                                                                                                      $begingroup$


                                                                                                                                                      PowerShell, 51 bytes





                                                                                                                                                      filter f{$_
                                                                                                                                                      if($_-gt9){("$_"|% t*y)-join'*'|iex|f}}


                                                                                                                                                      Try it online!






                                                                                                                                                      share|improve this answer









                                                                                                                                                      $endgroup$


















                                                                                                                                                        4












                                                                                                                                                        $begingroup$


                                                                                                                                                        PowerShell, 51 bytes





                                                                                                                                                        filter f{$_
                                                                                                                                                        if($_-gt9){("$_"|% t*y)-join'*'|iex|f}}


                                                                                                                                                        Try it online!






                                                                                                                                                        share|improve this answer









                                                                                                                                                        $endgroup$
















                                                                                                                                                          4












                                                                                                                                                          4








                                                                                                                                                          4





                                                                                                                                                          $begingroup$


                                                                                                                                                          PowerShell, 51 bytes





                                                                                                                                                          filter f{$_
                                                                                                                                                          if($_-gt9){("$_"|% t*y)-join'*'|iex|f}}


                                                                                                                                                          Try it online!






                                                                                                                                                          share|improve this answer









                                                                                                                                                          $endgroup$




                                                                                                                                                          PowerShell, 51 bytes





                                                                                                                                                          filter f{$_
                                                                                                                                                          if($_-gt9){("$_"|% t*y)-join'*'|iex|f}}


                                                                                                                                                          Try it online!







                                                                                                                                                          share|improve this answer












                                                                                                                                                          share|improve this answer



                                                                                                                                                          share|improve this answer










                                                                                                                                                          answered Mar 21 at 16:31









                                                                                                                                                          mazzymazzy

                                                                                                                                                          2,8951317




                                                                                                                                                          2,8951317























                                                                                                                                                              4












                                                                                                                                                              $begingroup$

                                                                                                                                                              Haskell, 45 bytes



                                                                                                                                                              f n=n:[x|n>9,x<-f$product$read.pure<$>show n]


                                                                                                                                                              Try it online!






                                                                                                                                                              share|improve this answer









                                                                                                                                                              $endgroup$


















                                                                                                                                                                4












                                                                                                                                                                $begingroup$

                                                                                                                                                                Haskell, 45 bytes



                                                                                                                                                                f n=n:[x|n>9,x<-f$product$read.pure<$>show n]


                                                                                                                                                                Try it online!






                                                                                                                                                                share|improve this answer









                                                                                                                                                                $endgroup$
















                                                                                                                                                                  4












                                                                                                                                                                  4








                                                                                                                                                                  4





                                                                                                                                                                  $begingroup$

                                                                                                                                                                  Haskell, 45 bytes



                                                                                                                                                                  f n=n:[x|n>9,x<-f$product$read.pure<$>show n]


                                                                                                                                                                  Try it online!






                                                                                                                                                                  share|improve this answer









                                                                                                                                                                  $endgroup$



                                                                                                                                                                  Haskell, 45 bytes



                                                                                                                                                                  f n=n:[x|n>9,x<-f$product$read.pure<$>show n]


                                                                                                                                                                  Try it online!







                                                                                                                                                                  share|improve this answer












                                                                                                                                                                  share|improve this answer



                                                                                                                                                                  share|improve this answer










                                                                                                                                                                  answered Mar 21 at 17:42









                                                                                                                                                                  niminimi

                                                                                                                                                                  32.4k32389




                                                                                                                                                                  32.4k32389























                                                                                                                                                                      4












                                                                                                                                                                      $begingroup$


                                                                                                                                                                      PHP, 63 bytes





                                                                                                                                                                      <?=$n=$argn;while($n>9)echo"
                                                                                                                                                                      ",$n=array_product(str_split($n));


                                                                                                                                                                      Iterative version, call with php -nF input from STDIN.



                                                                                                                                                                      Try it online!




                                                                                                                                                                      PHP, 72 71 bytes





                                                                                                                                                                      function h($n){echo"$n
                                                                                                                                                                      ",($n=array_product(str_split($n)))>9?h($n):$n;}


                                                                                                                                                                      Try it online!



                                                                                                                                                                      Recursive version, as function.



                                                                                                                                                                      Input: 277777788888899



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


                                                                                                                                                                      Input: 23



                                                                                                                                                                      23
                                                                                                                                                                      6





                                                                                                                                                                      share|improve this answer











                                                                                                                                                                      $endgroup$


















                                                                                                                                                                        4












                                                                                                                                                                        $begingroup$


                                                                                                                                                                        PHP, 63 bytes





                                                                                                                                                                        <?=$n=$argn;while($n>9)echo"
                                                                                                                                                                        ",$n=array_product(str_split($n));


                                                                                                                                                                        Iterative version, call with php -nF input from STDIN.



                                                                                                                                                                        Try it online!




                                                                                                                                                                        PHP, 72 71 bytes





                                                                                                                                                                        function h($n){echo"$n
                                                                                                                                                                        ",($n=array_product(str_split($n)))>9?h($n):$n;}


                                                                                                                                                                        Try it online!



                                                                                                                                                                        Recursive version, as function.



                                                                                                                                                                        Input: 277777788888899



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


                                                                                                                                                                        Input: 23



                                                                                                                                                                        23
                                                                                                                                                                        6





                                                                                                                                                                        share|improve this answer











                                                                                                                                                                        $endgroup$
















                                                                                                                                                                          4












                                                                                                                                                                          4








                                                                                                                                                                          4





                                                                                                                                                                          $begingroup$


                                                                                                                                                                          PHP, 63 bytes





                                                                                                                                                                          <?=$n=$argn;while($n>9)echo"
                                                                                                                                                                          ",$n=array_product(str_split($n));


                                                                                                                                                                          Iterative version, call with php -nF input from STDIN.



                                                                                                                                                                          Try it online!




                                                                                                                                                                          PHP, 72 71 bytes





                                                                                                                                                                          function h($n){echo"$n
                                                                                                                                                                          ",($n=array_product(str_split($n)))>9?h($n):$n;}


                                                                                                                                                                          Try it online!



                                                                                                                                                                          Recursive version, as function.



                                                                                                                                                                          Input: 277777788888899



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


                                                                                                                                                                          Input: 23



                                                                                                                                                                          23
                                                                                                                                                                          6





                                                                                                                                                                          share|improve this answer











                                                                                                                                                                          $endgroup$




                                                                                                                                                                          PHP, 63 bytes





                                                                                                                                                                          <?=$n=$argn;while($n>9)echo"
                                                                                                                                                                          ",$n=array_product(str_split($n));


                                                                                                                                                                          Iterative version, call with php -nF input from STDIN.



                                                                                                                                                                          Try it online!




                                                                                                                                                                          PHP, 72 71 bytes





                                                                                                                                                                          function h($n){echo"$n
                                                                                                                                                                          ",($n=array_product(str_split($n)))>9?h($n):$n;}


                                                                                                                                                                          Try it online!



                                                                                                                                                                          Recursive version, as function.



                                                                                                                                                                          Input: 277777788888899



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


                                                                                                                                                                          Input: 23



                                                                                                                                                                          23
                                                                                                                                                                          6






                                                                                                                                                                          share|improve this answer














                                                                                                                                                                          share|improve this answer



                                                                                                                                                                          share|improve this answer








                                                                                                                                                                          edited Mar 21 at 18:06

























                                                                                                                                                                          answered Mar 21 at 16:20









                                                                                                                                                                          gwaughgwaugh

                                                                                                                                                                          1,948515




                                                                                                                                                                          1,948515























                                                                                                                                                                              4












                                                                                                                                                                              $begingroup$


                                                                                                                                                                              J, 16 bytes



                                                                                                                                                                              ([:*/,.&.":)^:a:


                                                                                                                                                                              Try it online!






                                                                                                                                                                              share|improve this answer









                                                                                                                                                                              $endgroup$


















                                                                                                                                                                                4












                                                                                                                                                                                $begingroup$


                                                                                                                                                                                J, 16 bytes



                                                                                                                                                                                ([:*/,.&.":)^:a:


                                                                                                                                                                                Try it online!






                                                                                                                                                                                share|improve this answer









                                                                                                                                                                                $endgroup$
















                                                                                                                                                                                  4












                                                                                                                                                                                  4








                                                                                                                                                                                  4





                                                                                                                                                                                  $begingroup$


                                                                                                                                                                                  J, 16 bytes



                                                                                                                                                                                  ([:*/,.&.":)^:a:


                                                                                                                                                                                  Try it online!






                                                                                                                                                                                  share|improve this answer









                                                                                                                                                                                  $endgroup$




                                                                                                                                                                                  J, 16 bytes



                                                                                                                                                                                  ([:*/,.&.":)^:a:


                                                                                                                                                                                  Try it online!







                                                                                                                                                                                  share|improve this answer












                                                                                                                                                                                  share|improve this answer



                                                                                                                                                                                  share|improve this answer










                                                                                                                                                                                  answered Mar 21 at 19:05









                                                                                                                                                                                  Galen IvanovGalen Ivanov

                                                                                                                                                                                  7,24211034




                                                                                                                                                                                  7,24211034























                                                                                                                                                                                      4












                                                                                                                                                                                      $begingroup$


                                                                                                                                                                                      Ruby, 38 35 34 bytes





                                                                                                                                                                                      f=->n{p(n)>9&&f[eval n.digits*?*]}


                                                                                                                                                                                      Try it online!



                                                                                                                                                                                      1 byte saved by by G B.






                                                                                                                                                                                      share|improve this answer











                                                                                                                                                                                      $endgroup$


















                                                                                                                                                                                        4












                                                                                                                                                                                        $begingroup$


                                                                                                                                                                                        Ruby, 38 35 34 bytes





                                                                                                                                                                                        f=->n{p(n)>9&&f[eval n.digits*?*]}


                                                                                                                                                                                        Try it online!



                                                                                                                                                                                        1 byte saved by by G B.






                                                                                                                                                                                        share|improve this answer











                                                                                                                                                                                        $endgroup$
















                                                                                                                                                                                          4












                                                                                                                                                                                          4








                                                                                                                                                                                          4





                                                                                                                                                                                          $begingroup$


                                                                                                                                                                                          Ruby, 38 35 34 bytes





                                                                                                                                                                                          f=->n{p(n)>9&&f[eval n.digits*?*]}


                                                                                                                                                                                          Try it online!



                                                                                                                                                                                          1 byte saved by by G B.






                                                                                                                                                                                          share|improve this answer











                                                                                                                                                                                          $endgroup$




                                                                                                                                                                                          Ruby, 38 35 34 bytes





                                                                                                                                                                                          f=->n{p(n)>9&&f[eval n.digits*?*]}


                                                                                                                                                                                          Try it online!



                                                                                                                                                                                          1 byte saved by by G B.







                                                                                                                                                                                          share|improve this answer














                                                                                                                                                                                          share|improve this answer



                                                                                                                                                                                          share|improve this answer








                                                                                                                                                                                          edited 2 days ago

























                                                                                                                                                                                          answered Mar 21 at 14:29









                                                                                                                                                                                          Kirill L.Kirill L.

                                                                                                                                                                                          5,6831525




                                                                                                                                                                                          5,6831525























                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              Brachylog, 7 bytes



                                                                                                                                                                                              ẉ?Ḋ|ẹ×↰


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Explanation



                                                                                                                                                                                              ẉ          Write the input followed by a linebreak
                                                                                                                                                                                              ?Ḋ If the input is a single digit, then it's over
                                                                                                                                                                                              | Otherwise
                                                                                                                                                                                              ẹ Split the input into a list of digits
                                                                                                                                                                                              × Multiply them together
                                                                                                                                                                                              ↰ Recursive call with the result of the multiplication as input





                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Kroppeb
                                                                                                                                                                                                Mar 21 at 19:33


















                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              Brachylog, 7 bytes



                                                                                                                                                                                              ẉ?Ḋ|ẹ×↰


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Explanation



                                                                                                                                                                                              ẉ          Write the input followed by a linebreak
                                                                                                                                                                                              ?Ḋ If the input is a single digit, then it's over
                                                                                                                                                                                              | Otherwise
                                                                                                                                                                                              ẹ Split the input into a list of digits
                                                                                                                                                                                              × Multiply them together
                                                                                                                                                                                              ↰ Recursive call with the result of the multiplication as input





                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Kroppeb
                                                                                                                                                                                                Mar 21 at 19:33
















                                                                                                                                                                                              3












                                                                                                                                                                                              3








                                                                                                                                                                                              3





                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              Brachylog, 7 bytes



                                                                                                                                                                                              ẉ?Ḋ|ẹ×↰


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Explanation



                                                                                                                                                                                              ẉ          Write the input followed by a linebreak
                                                                                                                                                                                              ?Ḋ If the input is a single digit, then it's over
                                                                                                                                                                                              | Otherwise
                                                                                                                                                                                              ẹ Split the input into a list of digits
                                                                                                                                                                                              × Multiply them together
                                                                                                                                                                                              ↰ Recursive call with the result of the multiplication as input





                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                              $endgroup$




                                                                                                                                                                                              Brachylog, 7 bytes



                                                                                                                                                                                              ẉ?Ḋ|ẹ×↰


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Explanation



                                                                                                                                                                                              ẉ          Write the input followed by a linebreak
                                                                                                                                                                                              ?Ḋ If the input is a single digit, then it's over
                                                                                                                                                                                              | Otherwise
                                                                                                                                                                                              ẹ Split the input into a list of digits
                                                                                                                                                                                              × Multiply them together
                                                                                                                                                                                              ↰ Recursive call with the result of the multiplication as input






                                                                                                                                                                                              share|improve this answer












                                                                                                                                                                                              share|improve this answer



                                                                                                                                                                                              share|improve this answer










                                                                                                                                                                                              answered Mar 21 at 14:32









                                                                                                                                                                                              FatalizeFatalize

                                                                                                                                                                                              27.8k448136




                                                                                                                                                                                              27.8k448136












                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Kroppeb
                                                                                                                                                                                                Mar 21 at 19:33




















                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Kroppeb
                                                                                                                                                                                                Mar 21 at 19:33


















                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                              I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                              – Kroppeb
                                                                                                                                                                                              Mar 21 at 19:33






                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                              I gave it a try myself. Forgot about the Ḋ. The rest i had the same.
                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                              – Kroppeb
                                                                                                                                                                                              Mar 21 at 19:33













                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              JavaScript (Babel Node), 46 bytes





                                                                                                                                                                                              f=a=>a>9?[a,...f(eval([...a+''].join`*`))]:[a]


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              JavaScript (Babel Node), 44 bytes



                                                                                                                                                                                              If the input can be taken as String





                                                                                                                                                                                              f=a=>a>9?[a,...f(''+eval([...a].join`*`))]:a


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Luis felipe De jesus Munoz
                                                                                                                                                                                                Mar 21 at 15:12
















                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              JavaScript (Babel Node), 46 bytes





                                                                                                                                                                                              f=a=>a>9?[a,...f(eval([...a+''].join`*`))]:[a]


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              JavaScript (Babel Node), 44 bytes



                                                                                                                                                                                              If the input can be taken as String





                                                                                                                                                                                              f=a=>a>9?[a,...f(''+eval([...a].join`*`))]:a


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Luis felipe De jesus Munoz
                                                                                                                                                                                                Mar 21 at 15:12














                                                                                                                                                                                              3












                                                                                                                                                                                              3








                                                                                                                                                                                              3





                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              JavaScript (Babel Node), 46 bytes





                                                                                                                                                                                              f=a=>a>9?[a,...f(eval([...a+''].join`*`))]:[a]


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              JavaScript (Babel Node), 44 bytes



                                                                                                                                                                                              If the input can be taken as String





                                                                                                                                                                                              f=a=>a>9?[a,...f(''+eval([...a].join`*`))]:a


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                              $endgroup$




                                                                                                                                                                                              JavaScript (Babel Node), 46 bytes





                                                                                                                                                                                              f=a=>a>9?[a,...f(eval([...a+''].join`*`))]:[a]


                                                                                                                                                                                              Try it online!






                                                                                                                                                                                              JavaScript (Babel Node), 44 bytes



                                                                                                                                                                                              If the input can be taken as String





                                                                                                                                                                                              f=a=>a>9?[a,...f(''+eval([...a].join`*`))]:a


                                                                                                                                                                                              Try it online!







                                                                                                                                                                                              share|improve this answer














                                                                                                                                                                                              share|improve this answer



                                                                                                                                                                                              share|improve this answer








                                                                                                                                                                                              edited Mar 21 at 15:11

























                                                                                                                                                                                              answered Mar 21 at 14:29









                                                                                                                                                                                              Luis felipe De jesus MunozLuis felipe De jesus Munoz

                                                                                                                                                                                              5,67821671




                                                                                                                                                                                              5,67821671












                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Luis felipe De jesus Munoz
                                                                                                                                                                                                Mar 21 at 15:12


















                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – Luis felipe De jesus Munoz
                                                                                                                                                                                                Mar 21 at 15:12
















                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                              @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                              – Luis felipe De jesus Munoz
                                                                                                                                                                                              Mar 21 at 15:12




                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                              @Arnauld Yes, I just edited and added the wrong code. Im still looking for something using only strings instead arrays
                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                              – Luis felipe De jesus Munoz
                                                                                                                                                                                              Mar 21 at 15:12











                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              PowerShell, 64 59 bytes





                                                                                                                                                                                              for($a="$args";9-lt$a){$a;$a="$(($a|% t*y)-join'*'|iex)"}$a


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Iterative method. Takes input and stores it into $a, then enters a for loop so long as the length of $a is two or more (i.e., it's bigger than 9). Inside the loop we output $a and then recalculate it by converting it toCharArray, joining it together with *, and then iex (short for Invoke-Expression and similar to eval). Once we're out of the loop, we have a single digit left to print, so we place $a onto the pipeline again.



                                                                                                                                                                                              -5 bytes thanks to KGlasier.






                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – KGlasier
                                                                                                                                                                                                Mar 21 at 16:22
















                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              PowerShell, 64 59 bytes





                                                                                                                                                                                              for($a="$args";9-lt$a){$a;$a="$(($a|% t*y)-join'*'|iex)"}$a


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Iterative method. Takes input and stores it into $a, then enters a for loop so long as the length of $a is two or more (i.e., it's bigger than 9). Inside the loop we output $a and then recalculate it by converting it toCharArray, joining it together with *, and then iex (short for Invoke-Expression and similar to eval). Once we're out of the loop, we have a single digit left to print, so we place $a onto the pipeline again.



                                                                                                                                                                                              -5 bytes thanks to KGlasier.






                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – KGlasier
                                                                                                                                                                                                Mar 21 at 16:22














                                                                                                                                                                                              3












                                                                                                                                                                                              3








                                                                                                                                                                                              3





                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                              PowerShell, 64 59 bytes





                                                                                                                                                                                              for($a="$args";9-lt$a){$a;$a="$(($a|% t*y)-join'*'|iex)"}$a


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Iterative method. Takes input and stores it into $a, then enters a for loop so long as the length of $a is two or more (i.e., it's bigger than 9). Inside the loop we output $a and then recalculate it by converting it toCharArray, joining it together with *, and then iex (short for Invoke-Expression and similar to eval). Once we're out of the loop, we have a single digit left to print, so we place $a onto the pipeline again.



                                                                                                                                                                                              -5 bytes thanks to KGlasier.






                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                              $endgroup$




                                                                                                                                                                                              PowerShell, 64 59 bytes





                                                                                                                                                                                              for($a="$args";9-lt$a){$a;$a="$(($a|% t*y)-join'*'|iex)"}$a


                                                                                                                                                                                              Try it online!



                                                                                                                                                                                              Iterative method. Takes input and stores it into $a, then enters a for loop so long as the length of $a is two or more (i.e., it's bigger than 9). Inside the loop we output $a and then recalculate it by converting it toCharArray, joining it together with *, and then iex (short for Invoke-Expression and similar to eval). Once we're out of the loop, we have a single digit left to print, so we place $a onto the pipeline again.



                                                                                                                                                                                              -5 bytes thanks to KGlasier.







                                                                                                                                                                                              share|improve this answer














                                                                                                                                                                                              share|improve this answer



                                                                                                                                                                                              share|improve this answer








                                                                                                                                                                                              edited Mar 21 at 16:29

























                                                                                                                                                                                              answered Mar 21 at 14:49









                                                                                                                                                                                              AdmBorkBorkAdmBorkBork

                                                                                                                                                                                              27.5k466237




                                                                                                                                                                                              27.5k466237












                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – KGlasier
                                                                                                                                                                                                Mar 21 at 16:22


















                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                – KGlasier
                                                                                                                                                                                                Mar 21 at 16:22
















                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                              You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                              – KGlasier
                                                                                                                                                                                              Mar 21 at 16:22




                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                              You could use the comparison 9-lt$a instead of $a.length-1 to save 5 bytes. And if you didn't go string based the whole time you could cut off a decent chunk. Check out my powershell attempt if you want!
                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                              – KGlasier
                                                                                                                                                                                              Mar 21 at 16:22











                                                                                                                                                                                              3












                                                                                                                                                                                              $begingroup$

                                                                                                                                                                                              APL(NARS), 19 chars, 38 bytes



                                                                                                                                                                                              {⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}


                                                                                                                                                                                              test:



                                                                                                                                                                                                 f←{⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}
                                                                                                                                                                                              f 23
                                                                                                                                                                                              23
                                                                                                                                                                                              6
                                                                                                                                                                                              f 27648
                                                                                                                                                                                              27648
                                                                                                                                                                                              2688
                                                                                                                                                                                              768
                                                                                                                                                                                              336
                                                                                                                                                                                              54
                                                                                                                                                                                              20
                                                                                                                                                                                              0





                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                              $endgroup$


















                                                                                                                                                                                                3












                                                                                                                                                                                                $begingroup$

                                                                                                                                                                                                APL(NARS), 19 chars, 38 bytes



                                                                                                                                                                                                {⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}


                                                                                                                                                                                                test:



                                                                                                                                                                                                   f←{⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}
                                                                                                                                                                                                f 23
                                                                                                                                                                                                23
                                                                                                                                                                                                6
                                                                                                                                                                                                f 27648
                                                                                                                                                                                                27648
                                                                                                                                                                                                2688
                                                                                                                                                                                                768
                                                                                                                                                                                                336
                                                                                                                                                                                                54
                                                                                                                                                                                                20
                                                                                                                                                                                                0





                                                                                                                                                                                                share|improve this answer









                                                                                                                                                                                                $endgroup$
















                                                                                                                                                                                                  3












                                                                                                                                                                                                  3








                                                                                                                                                                                                  3





                                                                                                                                                                                                  $begingroup$

                                                                                                                                                                                                  APL(NARS), 19 chars, 38 bytes



                                                                                                                                                                                                  {⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}


                                                                                                                                                                                                  test:



                                                                                                                                                                                                     f←{⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}
                                                                                                                                                                                                  f 23
                                                                                                                                                                                                  23
                                                                                                                                                                                                  6
                                                                                                                                                                                                  f 27648
                                                                                                                                                                                                  27648
                                                                                                                                                                                                  2688
                                                                                                                                                                                                  768
                                                                                                                                                                                                  336
                                                                                                                                                                                                  54
                                                                                                                                                                                                  20
                                                                                                                                                                                                  0





                                                                                                                                                                                                  share|improve this answer









                                                                                                                                                                                                  $endgroup$



                                                                                                                                                                                                  APL(NARS), 19 chars, 38 bytes



                                                                                                                                                                                                  {⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}


                                                                                                                                                                                                  test:



                                                                                                                                                                                                     f←{⍵≤9:⍵⋄∇×/⍎¨⍕⍵⊣⎕←⍵}
                                                                                                                                                                                                  f 23
                                                                                                                                                                                                  23
                                                                                                                                                                                                  6
                                                                                                                                                                                                  f 27648
                                                                                                                                                                                                  27648
                                                                                                                                                                                                  2688
                                                                                                                                                                                                  768
                                                                                                                                                                                                  336
                                                                                                                                                                                                  54
                                                                                                                                                                                                  20
                                                                                                                                                                                                  0






                                                                                                                                                                                                  share|improve this answer












                                                                                                                                                                                                  share|improve this answer



                                                                                                                                                                                                  share|improve this answer










                                                                                                                                                                                                  answered Mar 21 at 16:41









                                                                                                                                                                                                  RosLuPRosLuP

                                                                                                                                                                                                  2,276514




                                                                                                                                                                                                  2,276514























                                                                                                                                                                                                      3












                                                                                                                                                                                                      $begingroup$


                                                                                                                                                                                                      Charcoal, 13 bytes



                                                                                                                                                                                                      θW⊖Lθ«≔IΠθθ⸿θ


                                                                                                                                                                                                      Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                                                                      θ


                                                                                                                                                                                                      Print the input for the first time.



                                                                                                                                                                                                      W⊖Lθ«


                                                                                                                                                                                                      Repeat while the length of the input is not 1.



                                                                                                                                                                                                      ≔IΠθθ


                                                                                                                                                                                                      Replace the input with its digital product cast to string.



                                                                                                                                                                                                      ⸿θ


                                                                                                                                                                                                      Print the input on a new line.






                                                                                                                                                                                                      share|improve this answer









                                                                                                                                                                                                      $endgroup$


















                                                                                                                                                                                                        3












                                                                                                                                                                                                        $begingroup$


                                                                                                                                                                                                        Charcoal, 13 bytes



                                                                                                                                                                                                        θW⊖Lθ«≔IΠθθ⸿θ


                                                                                                                                                                                                        Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                                                                        θ


                                                                                                                                                                                                        Print the input for the first time.



                                                                                                                                                                                                        W⊖Lθ«


                                                                                                                                                                                                        Repeat while the length of the input is not 1.



                                                                                                                                                                                                        ≔IΠθθ


                                                                                                                                                                                                        Replace the input with its digital product cast to string.



                                                                                                                                                                                                        ⸿θ


                                                                                                                                                                                                        Print the input on a new line.






                                                                                                                                                                                                        share|improve this answer









                                                                                                                                                                                                        $endgroup$
















                                                                                                                                                                                                          3












                                                                                                                                                                                                          3








                                                                                                                                                                                                          3





                                                                                                                                                                                                          $begingroup$


                                                                                                                                                                                                          Charcoal, 13 bytes



                                                                                                                                                                                                          θW⊖Lθ«≔IΠθθ⸿θ


                                                                                                                                                                                                          Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                                                                          θ


                                                                                                                                                                                                          Print the input for the first time.



                                                                                                                                                                                                          W⊖Lθ«


                                                                                                                                                                                                          Repeat while the length of the input is not 1.



                                                                                                                                                                                                          ≔IΠθθ


                                                                                                                                                                                                          Replace the input with its digital product cast to string.



                                                                                                                                                                                                          ⸿θ


                                                                                                                                                                                                          Print the input on a new line.






                                                                                                                                                                                                          share|improve this answer









                                                                                                                                                                                                          $endgroup$




                                                                                                                                                                                                          Charcoal, 13 bytes



                                                                                                                                                                                                          θW⊖Lθ«≔IΠθθ⸿θ


                                                                                                                                                                                                          Try it online! Link is to verbose version of code. Explanation:



                                                                                                                                                                                                          θ


                                                                                                                                                                                                          Print the input for the first time.



                                                                                                                                                                                                          W⊖Lθ«


                                                                                                                                                                                                          Repeat while the length of the input is not 1.



                                                                                                                                                                                                          ≔IΠθθ


                                                                                                                                                                                                          Replace the input with its digital product cast to string.



                                                                                                                                                                                                          ⸿θ


                                                                                                                                                                                                          Print the input on a new line.







                                                                                                                                                                                                          share|improve this answer












                                                                                                                                                                                                          share|improve this answer



                                                                                                                                                                                                          share|improve this answer










                                                                                                                                                                                                          answered Mar 21 at 16:48









                                                                                                                                                                                                          NeilNeil

                                                                                                                                                                                                          82k745178




                                                                                                                                                                                                          82k745178























                                                                                                                                                                                                              3












                                                                                                                                                                                                              $begingroup$


                                                                                                                                                                                                              C (gcc), 58 bytes





                                                                                                                                                                                                              f(n,t){for(;n=printf("%dn",t=n)>2;)for(;n*=t%10,t/=10;);}


                                                                                                                                                                                                              Try it online!



                                                                                                                                                                                                              Iterative approach turns out to be 1 byte shorter.



                                                                                                                                                                                                              f(n,t){
                                                                                                                                                                                                              for(;n=printf("%dn",t=n) //print and update current number
                                                                                                                                                                                                              >2;) //until only one digit is printed
                                                                                                                                                                                                              for(;n*=t%10,t/=10;); //n*= product of digits of t (step)
                                                                                                                                                                                                              }





                                                                                                                                                                                                              C (gcc), 61 59 bytes (recursive)





                                                                                                                                                                                                              f(n){printf("%dn",n)>2&&f(p(n));}p(n){n=n?n%10*p(n/10):1;}


                                                                                                                                                                                                              Try it online!



                                                                                                                                                                                                              Recursion seems to be shorter than iteration for both print and step...






                                                                                                                                                                                                              share|improve this answer











                                                                                                                                                                                                              $endgroup$


















                                                                                                                                                                                                                3












                                                                                                                                                                                                                $begingroup$


                                                                                                                                                                                                                C (gcc), 58 bytes





                                                                                                                                                                                                                f(n,t){for(;n=printf("%dn",t=n)>2;)for(;n*=t%10,t/=10;);}


                                                                                                                                                                                                                Try it online!



                                                                                                                                                                                                                Iterative approach turns out to be 1 byte shorter.



                                                                                                                                                                                                                f(n,t){
                                                                                                                                                                                                                for(;n=printf("%dn",t=n) //print and update current number
                                                                                                                                                                                                                >2;) //until only one digit is printed
                                                                                                                                                                                                                for(;n*=t%10,t/=10;); //n*= product of digits of t (step)
                                                                                                                                                                                                                }





                                                                                                                                                                                                                C (gcc), 61 59 bytes (recursive)





                                                                                                                                                                                                                f(n){printf("%dn",n)>2&&f(p(n));}p(n){n=n?n%10*p(n/10):1;}


                                                                                                                                                                                                                Try it online!



                                                                                                                                                                                                                Recursion seems to be shorter than iteration for both print and step...






                                                                                                                                                                                                                share|improve this answer











                                                                                                                                                                                                                $endgroup$
















                                                                                                                                                                                                                  3












                                                                                                                                                                                                                  3








                                                                                                                                                                                                                  3





                                                                                                                                                                                                                  $begingroup$


                                                                                                                                                                                                                  C (gcc), 58 bytes





                                                                                                                                                                                                                  f(n,t){for(;n=printf("%dn",t=n)>2;)for(;n*=t%10,t/=10;);}


                                                                                                                                                                                                                  Try it online!



                                                                                                                                                                                                                  Iterative approach turns out to be 1 byte shorter.



                                                                                                                                                                                                                  f(n,t){
                                                                                                                                                                                                                  for(;n=printf("%dn",t=n) //print and update current number
                                                                                                                                                                                                                  >2;) //until only one digit is printed
                                                                                                                                                                                                                  for(;n*=t%10,t/=10;); //n*= product of digits of t (step)
                                                                                                                                                                                                                  }





                                                                                                                                                                                                                  C (gcc), 61 59 bytes (recursive)





                                                                                                                                                                                                                  f(n){printf("%dn",n)>2&&f(p(n));}p(n){n=n?n%10*p(n/10):1;}


                                                                                                                                                                                                                  Try it online!



                                                                                                                                                                                                                  Recursion seems to be shorter than iteration for both print and step...






                                                                                                                                                                                                                  share|improve this answer











                                                                                                                                                                                                                  $endgroup$




                                                                                                                                                                                                                  C (gcc), 58 bytes





                                                                                                                                                                                                                  f(n,t){for(;n=printf("%dn",t=n)>2;)for(;n*=t%10,t/=10;);}


                                                                                                                                                                                                                  Try it online!



                                                                                                                                                                                                                  Iterative approach turns out to be 1 byte shorter.



                                                                                                                                                                                                                  f(n,t){
                                                                                                                                                                                                                  for(;n=printf("%dn",t=n) //print and update current number
                                                                                                                                                                                                                  >2;) //until only one digit is printed
                                                                                                                                                                                                                  for(;n*=t%10,t/=10;); //n*= product of digits of t (step)
                                                                                                                                                                                                                  }





                                                                                                                                                                                                                  C (gcc), 61 59 bytes (recursive)





                                                                                                                                                                                                                  f(n){printf("%dn",n)>2&&f(p(n));}p(n){n=n?n%10*p(n/10):1;}


                                                                                                                                                                                                                  Try it online!



                                                                                                                                                                                                                  Recursion seems to be shorter than iteration for both print and step...







                                                                                                                                                                                                                  share|improve this answer














                                                                                                                                                                                                                  share|improve this answer



                                                                                                                                                                                                                  share|improve this answer








                                                                                                                                                                                                                  edited 21 hours ago

























                                                                                                                                                                                                                  answered 2 days ago









                                                                                                                                                                                                                  attinatattinat

                                                                                                                                                                                                                  4105




                                                                                                                                                                                                                  4105























                                                                                                                                                                                                                      2












                                                                                                                                                                                                                      $begingroup$


                                                                                                                                                                                                                      Retina, 24 bytes



                                                                                                                                                                                                                      .+~(`

                                                                                                                                                                                                                      .
                                                                                                                                                                                                                      $&$*
                                                                                                                                                                                                                      ^
                                                                                                                                                                                                                      .+¶$$.(


                                                                                                                                                                                                                      Try it online! Explanation:



                                                                                                                                                                                                                      .+~(`


                                                                                                                                                                                                                      Print the current value on its own line at the start of every loop until it stops changing and don't print the unchanged value twice. Evaluate the current value at the end of each loop.



                                                                                                                                                                                                                      .
                                                                                                                                                                                                                      $&$*


                                                                                                                                                                                                                      Add a * after each digit.



                                                                                                                                                                                                                      ^
                                                                                                                                                                                                                      .+¶$$.(


                                                                                                                                                                                                                      Finish turning the input into an expression that evaluates to the digital product.



                                                                                                                                                                                                                      Just for the record, Retina can do this in one line (25 bytes):



                                                                                                                                                                                                                      .+"¶"<~[".+¶$.("|'*]'*L`.





                                                                                                                                                                                                                      share|improve this answer









                                                                                                                                                                                                                      $endgroup$


















                                                                                                                                                                                                                        2












                                                                                                                                                                                                                        $begingroup$


                                                                                                                                                                                                                        Retina, 24 bytes



                                                                                                                                                                                                                        .+~(`

                                                                                                                                                                                                                        .
                                                                                                                                                                                                                        $&$*
                                                                                                                                                                                                                        ^
                                                                                                                                                                                                                        .+¶$$.(


                                                                                                                                                                                                                        Try it online! Explanation:



                                                                                                                                                                                                                        .+~(`


                                                                                                                                                                                                                        Print the current value on its own line at the start of every loop until it stops changing and don't print the unchanged value twice. Evaluate the current value at the end of each loop.



                                                                                                                                                                                                                        .
                                                                                                                                                                                                                        $&$*


                                                                                                                                                                                                                        Add a * after each digit.



                                                                                                                                                                                                                        ^
                                                                                                                                                                                                                        .+¶$$.(


                                                                                                                                                                                                                        Finish turning the input into an expression that evaluates to the digital product.



                                                                                                                                                                                                                        Just for the record, Retina can do this in one line (25 bytes):



                                                                                                                                                                                                                        .+"¶"<~[".+¶$.("|'*]'*L`.





                                                                                                                                                                                                                        share|improve this answer









                                                                                                                                                                                                                        $endgroup$
















                                                                                                                                                                                                                          2












                                                                                                                                                                                                                          2








                                                                                                                                                                                                                          2





                                                                                                                                                                                                                          $begingroup$


                                                                                                                                                                                                                          Retina, 24 bytes



                                                                                                                                                                                                                          .+~(`

                                                                                                                                                                                                                          .
                                                                                                                                                                                                                          $&$*
                                                                                                                                                                                                                          ^
                                                                                                                                                                                                                          .+¶$$.(


                                                                                                                                                                                                                          Try it online! Explanation:



                                                                                                                                                                                                                          .+~(`


                                                                                                                                                                                                                          Print the current value on its own line at the start of every loop until it stops changing and don't print the unchanged value twice. Evaluate the current value at the end of each loop.



                                                                                                                                                                                                                          .
                                                                                                                                                                                                                          $&$*


                                                                                                                                                                                                                          Add a * after each digit.



                                                                                                                                                                                                                          ^
                                                                                                                                                                                                                          .+¶$$.(


                                                                                                                                                                                                                          Finish turning the input into an expression that evaluates to the digital product.



                                                                                                                                                                                                                          Just for the record, Retina can do this in one line (25 bytes):



                                                                                                                                                                                                                          .+"¶"<~[".+¶$.("|'*]'*L`.





                                                                                                                                                                                                                          share|improve this answer









                                                                                                                                                                                                                          $endgroup$




                                                                                                                                                                                                                          Retina, 24 bytes



                                                                                                                                                                                                                          .+~(`

                                                                                                                                                                                                                          .
                                                                                                                                                                                                                          $&$*
                                                                                                                                                                                                                          ^
                                                                                                                                                                                                                          .+¶$$.(


                                                                                                                                                                                                                          Try it online! Explanation:



                                                                                                                                                                                                                          .+~(`


                                                                                                                                                                                                                          Print the current value on its own line at the start of every loop until it stops changing and don't print the unchanged value twice. Evaluate the current value at the end of each loop.



                                                                                                                                                                                                                          .
                                                                                                                                                                                                                          $&$*


                                                                                                                                                                                                                          Add a * after each digit.



                                                                                                                                                                                                                          ^
                                                                                                                                                                                                                          .+¶$$.(


                                                                                                                                                                                                                          Finish turning the input into an expression that evaluates to the digital product.



                                                                                                                                                                                                                          Just for the record, Retina can do this in one line (25 bytes):



                                                                                                                                                                                                                          .+"¶"<~[".+¶$.("|'*]'*L`.






                                                                                                                                                                                                                          share|improve this answer












                                                                                                                                                                                                                          share|improve this answer



                                                                                                                                                                                                                          share|improve this answer










                                                                                                                                                                                                                          answered Mar 21 at 17:01









                                                                                                                                                                                                                          NeilNeil

                                                                                                                                                                                                                          82k745178




                                                                                                                                                                                                                          82k745178























                                                                                                                                                                                                                              2












                                                                                                                                                                                                                              $begingroup$

                                                                                                                                                                                                                              Java, 112 bytes



                                                                                                                                                                                                                              "Lossy conversion" thanks Java for the extra ~15 bytes


                                                                                                                                                                                                                              Obligatory stream abuse recursion answer



                                                                                                                                                                                                                              long f(long n){System.out.println(n);return n<10?n:f((n+"").chars().mapToLong(i->i).reduce(1,(x,y)->x*(y-48)));}


                                                                                                                                                                                                                              Try it online






                                                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                I'm pretty sure you only need to support int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                                                                                                2 days ago










                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Benjamin Urquhart
                                                                                                                                                                                                                                yesterday
















                                                                                                                                                                                                                              2












                                                                                                                                                                                                                              $begingroup$

                                                                                                                                                                                                                              Java, 112 bytes



                                                                                                                                                                                                                              "Lossy conversion" thanks Java for the extra ~15 bytes


                                                                                                                                                                                                                              Obligatory stream abuse recursion answer



                                                                                                                                                                                                                              long f(long n){System.out.println(n);return n<10?n:f((n+"").chars().mapToLong(i->i).reduce(1,(x,y)->x*(y-48)));}


                                                                                                                                                                                                                              Try it online






                                                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                                                              $endgroup$













                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                I'm pretty sure you only need to support int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                                                                                                2 days ago










                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Benjamin Urquhart
                                                                                                                                                                                                                                yesterday














                                                                                                                                                                                                                              2












                                                                                                                                                                                                                              2








                                                                                                                                                                                                                              2





                                                                                                                                                                                                                              $begingroup$

                                                                                                                                                                                                                              Java, 112 bytes



                                                                                                                                                                                                                              "Lossy conversion" thanks Java for the extra ~15 bytes


                                                                                                                                                                                                                              Obligatory stream abuse recursion answer



                                                                                                                                                                                                                              long f(long n){System.out.println(n);return n<10?n:f((n+"").chars().mapToLong(i->i).reduce(1,(x,y)->x*(y-48)));}


                                                                                                                                                                                                                              Try it online






                                                                                                                                                                                                                              share|improve this answer









                                                                                                                                                                                                                              $endgroup$



                                                                                                                                                                                                                              Java, 112 bytes



                                                                                                                                                                                                                              "Lossy conversion" thanks Java for the extra ~15 bytes


                                                                                                                                                                                                                              Obligatory stream abuse recursion answer



                                                                                                                                                                                                                              long f(long n){System.out.println(n);return n<10?n:f((n+"").chars().mapToLong(i->i).reduce(1,(x,y)->x*(y-48)));}


                                                                                                                                                                                                                              Try it online







                                                                                                                                                                                                                              share|improve this answer












                                                                                                                                                                                                                              share|improve this answer



                                                                                                                                                                                                                              share|improve this answer










                                                                                                                                                                                                                              answered Mar 21 at 19:39









                                                                                                                                                                                                                              Benjamin UrquhartBenjamin Urquhart

                                                                                                                                                                                                                              3407




                                                                                                                                                                                                                              3407












                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                I'm pretty sure you only need to support int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                                                                                                2 days ago










                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Benjamin Urquhart
                                                                                                                                                                                                                                yesterday


















                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                I'm pretty sure you only need to support int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Embodiment of Ignorance
                                                                                                                                                                                                                                2 days ago










                                                                                                                                                                                                                              • $begingroup$
                                                                                                                                                                                                                                @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                                                                                                                                                                                                $endgroup$
                                                                                                                                                                                                                                – Benjamin Urquhart
                                                                                                                                                                                                                                yesterday
















                                                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                                                              I'm pretty sure you only need to support int
                                                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                                                              – Embodiment of Ignorance
                                                                                                                                                                                                                              2 days ago




                                                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                                                              I'm pretty sure you only need to support int
                                                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                                                              – Embodiment of Ignorance
                                                                                                                                                                                                                              2 days ago












                                                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                                                              @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                                                              – Benjamin Urquhart
                                                                                                                                                                                                                              yesterday




                                                                                                                                                                                                                              $begingroup$
                                                                                                                                                                                                                              @EmbodimentofIgnorance then it fails for 277777788888899 since 4996238671872 is too large for an int
                                                                                                                                                                                                                              $endgroup$
                                                                                                                                                                                                                              – Benjamin Urquhart
                                                                                                                                                                                                                              yesterday










                                                                                                                                                                                                                              1 2
                                                                                                                                                                                                                              next

















                                                                                                                                                                                                                              draft saved

                                                                                                                                                                                                                              draft discarded




















































                                                                                                                                                                                                                              If this is an answer to a challenge…




                                                                                                                                                                                                                              • …Be sure to follow the challenge specification. However, please refrain from exploiting obvious loopholes. Answers abusing any of the standard loopholes are considered invalid. If you think a specification is unclear or underspecified, comment on the question instead.


                                                                                                                                                                                                                              • …Try to optimize your score. For instance, answers to code-golf challenges should attempt to be as short as possible. You can always include a readable version of the code in addition to the competitive one.
                                                                                                                                                                                                                                Explanations of your answer make it more interesting to read and are very much encouraged.


                                                                                                                                                                                                                              • …Include a short header which indicates the language(s) of your code and its score, as defined by the challenge.



                                                                                                                                                                                                                              More generally…




                                                                                                                                                                                                                              • …Please make sure to answer the question and provide sufficient detail.


                                                                                                                                                                                                                              • …Avoid asking for help, clarification or responding to other answers (use comments instead).





                                                                                                                                                                                                                              draft saved


                                                                                                                                                                                                                              draft discarded














                                                                                                                                                                                                                              StackExchange.ready(
                                                                                                                                                                                                                              function () {
                                                                                                                                                                                                                              StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fcodegolf.stackexchange.com%2fquestions%2f181958%2fmultiplicative-persistence%23new-answer', 'question_page');
                                                                                                                                                                                                                              }
                                                                                                                                                                                                                              );

                                                                                                                                                                                                                              Post as a guest















                                                                                                                                                                                                                              Required, but never shown





















































                                                                                                                                                                                                                              Required, but never shown














                                                                                                                                                                                                                              Required, but never shown












                                                                                                                                                                                                                              Required, but never shown







                                                                                                                                                                                                                              Required, but never shown

































                                                                                                                                                                                                                              Required, but never shown














                                                                                                                                                                                                                              Required, but never shown












                                                                                                                                                                                                                              Required, but never shown







                                                                                                                                                                                                                              Required, but never shown







                                                                                                                                                                                                                              Popular posts from this blog

                                                                                                                                                                                                                              Plaza Victoria

                                                                                                                                                                                                                              In PowerPoint, is there a keyboard shortcut for bulleted / numbered list?

                                                                                                                                                                                                                              How to put 3 figures in Latex with 2 figures side by side and 1 below these side by side images but in...