How to resolve the algorithm Digital root/Multiplicative digital root step by step in the Icon and Unicon 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 Icon and Unicon 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 Icon and Unicon programming language
Source code in the icon programming language
procedure main(A)
write(right("n",8)," ",right("MP",8),right("MDR",5))
every r := mdr(n := 123321|7739|893|899998) do
write(right(n,8),":",right(r[1],8),right(r[2],5))
write()
write(right("MDR",5)," ","[n0..n4]")
every m := 0 to 9 do {
writes(right(m,5),": [")
every writes(right((m = mdr(n := seq(m))[2],.n)\5,6))
write("]")
}
end
procedure mdr(m)
i := 0
while (.m > 10, m := multd(m), i+:=1)
return [i,m]
end
procedure multd(m)
c := 1
while m > 0 do c *:= 1(m%10, m/:=10)
return c
end
You may also check:How to resolve the algorithm Sort using a custom comparator step by step in the zkl programming language
You may also check:How to resolve the algorithm Variable declaration reset step by step in the FreeBASIC programming language
You may also check:How to resolve the algorithm Roman numerals/Encode step by step in the Pike programming language
You may also check:How to resolve the algorithm Caesar cipher step by step in the Insitux programming language
You may also check:How to resolve the algorithm 100 doors step by step in the Egel programming language