Digital root/Multiplicative digital root: Difference between revisions

Added Easylang
m (→‎{{header|Wren}}: Minor tidy)
(Added Easylang)
 
Line 1,085:
}</syntaxhighlight>
The output is similar.
 
=={{header|EasyLang}}==
{{trans|C}}
<syntaxhighlight>
proc _mdr n . md mp .
if n > 0
r = 1
.
while n > 0
r *= n mod 10
n = n div 10
.
mp += 1
if r >= 10
_mdr r md mp
else
md = r
.
.
proc mdr n . md mp .
mp = 0
_mdr n md mp
.
numfmt 0 6
print "Number MDR MP"
for v in [ 123321 7739 893 899998 ]
mdr v md mp
print v & md & mp
.
width = 5
len table[] 10 * width
arrbase table[] 0
len tfill[] 10
arrbase tfill[] 0
numfmt 0 0
while total < 10 * width
mdr i md mp
if tfill[md] < width
table[md * width + tfill[md]] = i
tfill[md] += 1
total += 1
.
i += 1
.
print "\nMDR: [n0..n4]"
for i = 0 to 9
write i & ": ["
for j = 0 to width - 1
write table[i * width + j]
if j < width - 1
write ","
.
.
print "]"
.
</syntaxhighlight>
{{out}}
<pre>
Number MDR MP
123321 8 3
7739 8 3
893 2 3
899998 0 2
 
MDR: [n0..n4]
0: [0,10,20,25,30]
1: [1,11,111,1111,11111]
2: [2,12,21,26,34]
3: [3,13,31,113,131]
4: [4,14,22,27,39]
5: [5,15,35,51,53]
6: [6,16,23,28,32]
7: [7,17,71,117,171]
8: [8,18,24,29,36]
9: [9,19,33,91,119]
</pre>
 
=={{header|Elixir}}==
2,022

edits