Digital root/Multiplicative digital root: Difference between revisions

Content added Content deleted
(Added Wren)
(→‎{{header|Ruby}}: Use Ruby 2.4 method "digits")
Line 2,583: Line 2,583:


=={{header|Ruby}}==
=={{header|Ruby}}==
{{works with|Ruby|2.1}}
{{works with|Ruby|2.4}}
<lang ruby>def mdroot(n)
<lang ruby>def mdroot(n)
mdr, persist = n, 0
mdr, persist = n, 0
until mdr < 10 do
until mdr < 10 do
mdr = mdr.to_s.each_char.map(&:to_i).inject(:*)
mdr = mdr.digits.inject(:*)
persist += 1
persist += 1
end
end