How to resolve the algorithm Digital root/Multiplicative digital root step by step in the Quackery programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Digital root/Multiplicative digital root step by step in the Quackery programming language

Table of Contents

Problem Statement

The multiplicative digital root (MDR) and multiplicative persistence (MP) of a number,

n

{\displaystyle n}

, is calculated rather like the Digital root except digits are multiplied instead of being added:

Show all output on this page. The Product of decimal digits of n page was redirected here, and had the following description The three existing entries for Phix, REXX, and Ring have been moved here, under ===Similar=== headings, feel free to match or ignore them.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Digital root/Multiplicative digital root step by step in the Quackery programming language

Source code in the quackery programming language

  [ abs 1 swap 
    [ base share /mod 
      rot * swap 
      dup 0 = until ] 
    drop ]                       is digitproduct ( n --> n   )
 
  [ 0 swap 
    [ dup base share > while
      dip 1+ 
      digitproduct again ] ]     is mdr          ( n --> n n )
 
  [ dup mdr
    rot echo 
    say ": "
    swap echo 
    say ", "
    echo cr ]                    is task.1       ( n -->     )
 
  [ times 
      [ i^ [] swap dup rot
        [ unrot dup mdr nip 
          swap dip 
            [ over = ] 
          swap iff
            [ rot over join ]
          else rot
          dip 1+
          dup size 5 = until ]
        i^ echo say " : "
        echo cr 2drop ] ]       is task.2        ( n -->     )
     
  ' [ 123321 7739 893 899998 ] witheach task.1
  cr
  10 task.2

  

You may also check:How to resolve the algorithm A+B step by step in the LiveCode programming language
You may also check:How to resolve the algorithm Hamming numbers step by step in the JavaScript programming language
You may also check:How to resolve the algorithm Humble numbers step by step in the ALGOL W programming language
You may also check:How to resolve the algorithm Solve a Hopido puzzle step by step in the Icon and Unicon programming language
You may also check:How to resolve the algorithm Cheryl's birthday step by step in the V (Vlang) programming language