2016 Update

This commit is contained in:
Tina Müller 2016-12-05 22:15:40 +01:00
parent 948b86eafa
commit dcf5d15da3
7965 changed files with 139854 additions and 31002 deletions

View file

@ -5,10 +5,12 @@ The [[wp:Multiplicative digital root|multiplicative digital root]] (MDR) and mul
#* Increment <math>i</math>.
# Return <math>i</math> (= MP) and <math>m</math> (= MDR)
;Task:
* Tabulate the MP and MDR of the numbers 123321, 7739, 893, 899998
* Tabulate MDR versus the first five numbers having that MDR, something like:
<pre>MDR: [n0..n4]
<pre>
MDR: [n0..n4]
=== ========
0: [0, 10, 20, 25, 30]
1: [1, 11, 111, 1111, 11111]
@ -19,9 +21,12 @@ The [[wp:Multiplicative digital root|multiplicative digital root]] (MDR) and mul
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>
9: [9, 19, 33, 91, 119]
</pre>
Show all output on this page.
;References:
* [http://mathworld.wolfram.com/MultiplicativeDigitalRoot.html Multiplicative Digital Root] on Wolfram Mathworld.
* [http://oeis.org/A031347 Multiplicative digital root] on The On-Line Encyclopedia of Integer Sequences.
<br><br>

View file

@ -26,12 +26,12 @@ defmodule Digital do
defp add_map(n, m, map) do
{mdr, _persist} = mdroot(n)
new_map = Dict.update(map, mdr, [n], fn vals -> [n | vals] end)
min_len = Dict.values(new_map) |> Enum.map(&length(&1)) |> Enum.min
new_map = Map.update(map, mdr, [n], fn vals -> [n | vals] end)
min_len = Map.values(new_map) |> Enum.map(&length(&1)) |> Enum.min
if min_len < m, do: add_map(n+1, m, new_map),
else: new_map
end
end
Digital.task1([123321, 7739, 893, 899998])
Digital.task2(5)
Digital.task2

View file

@ -0,0 +1,3 @@
a(n)=my(i);while(n>9,n=factorback(digits(n));i++);[i,n];
apply(a, [123321, 7739, 893, 899998])
v=vector(10,i,[]); forstep(n=0,oo,1, t=a(n)[2]+1; if(#v[t]<5,v[t]=concat(v[t],n); if(vecmin(apply(length,v))>4, return(v))))

View file

@ -1,6 +1,6 @@
sub multiplicative-digital-root(Int $n) {
return .elems - 1, .[.end]
given $n, {[*] .comb} ... *.chars == 1
given cache($n, {[*] .comb} ... *.chars == 1)
}
for 123321, 7739, 893, 899998 {