Data update

This commit is contained in:
Ingy döt Net 2026-04-30 12:34:36 -04:00
parent 4bb20c9b71
commit cbaf4c4b64
12390 changed files with 318560 additions and 27248 deletions

View file

@ -0,0 +1,47 @@
with Ada.Text_IO, Generic_Root; use Generic_Root;
procedure Multiplicative_Root is
procedure Compute is new Compute_Root("*"); -- "*" for multiplicative roots
package TIO renames Ada.Text_IO;
package NIO is new TIO.Integer_IO(Number);
procedure Print_Numbers(Target_Root: Number; How_Many: Natural) is
Current: Number := 0;
Root, Pers: Number;
begin
for I in 1 .. How_Many loop
loop
Compute(Current, Root, Pers);
exit when Root = Target_Root;
Current := Current + 1;
end loop;
NIO.Put(Current, Width => 6);
if I < How_Many then
TIO.Put(",");
end if;
Current := Current + 1;
end loop;
end Print_Numbers;
Inputs: Number_Array := (123321, 7739, 893, 899998);
Root, Pers: Number;
begin
TIO.Put_Line(" Number MDR MP");
for I in Inputs'Range loop
Compute(Inputs(I), Root, Pers);
NIO.Put(Inputs(I), Width => 8);
NIO.Put(Root, Width => 6);
NIO.Put(Pers, Width => 6);
TIO.New_Line;
end loop;
TIO.New_Line;
TIO.Put_Line(" MDR first_five_numbers_with_that_MDR");
for I in 0 .. 9 loop
TIO.Put(" " & Integer'Image(I) & " ");
Print_Numbers(Target_Root => Number(I), How_Many => 5);
TIO.New_Line;
end loop;
end Multiplicative_Root;

View file

@ -0,0 +1,33 @@
struct Int
def mdr
n, p = self, 0
return {0, 0} unless n > 0
while n >= 10
n = n.digits.product
p += 1
end
{ n, p }
end
end
puts <<-EOH
n MDR MP
-------------
EOH
[123321, 7739, 893, 899998].each do |n|
printf "%6d %d %d\n", n, *n.mdr
end
puts
puts <<-EOH
MDR: [n0..n4]
=== ========
EOH
buckets = Array(Array(Int32)).new(10) { [] of Int32 }
(0..).each do |n|
mdr, _ = n.mdr
buckets[mdr] << n
break if buckets.all? {|b| b.size >= 5 }
end
buckets.each_with_index do |b, i|
printf "%3d: %s\n", i, b.first(5)
end

View file

@ -23,9 +23,7 @@ for v in [ 123321 7739 893 899998 ]
.
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

View file

@ -0,0 +1,31 @@
function digmul(n) {
return [...String(n)].reduce((x, y) => Number(x) * Number(y));
}
function mdr_mp(n) {
let m = n, i = 0;
while (m > 9) {
m = digmul(m);
i++;
}
return {"MDR": m, "MP": i};
}
for (const n of [123321, 7739, 893, 899998]) {
console.log(`${n} has MDR ${mdr_mp(n)["MDR"]} and MP ${mdr_mp(n)["MP"]}`);
}
function first5mdr(n) {
let m = 0, nums = [];
while (nums.length < 5) {
if (mdr_mp(m)["MDR"] == n) {
nums.push(m);
}
m++;
}
return `First 5 numbers with MDR ${n}: ${nums.join(", ")}`;
}
for (let i = 0; i < 10; i++) {
console.log(first5mdr(i));
}

View file

@ -0,0 +1,64 @@
local bigint = require "pluto:bigint"
local fmt = require "fmt"
local zero = bigint.new(0)
local one = bigint.new(1)
-- Only valid for n > 0 && base >= 2.
local function mult(n, base)
local m = one
while m > zero and n > zero do
local q, rem = n:div(base)
m *= rem
n = q
end
return m
end
-- Only valid for n >= 0 and base >= 2.
local function mult_digital_root(n, base)
base = bigint.new(base)
local m = n
local mp = zero
while m >= base do
m = mult(m, base)
mp += one
end
return {mp, tonumber(m:hex(), 16)}
end
local base = 10
local size = 5
local tests = {
123321, 7739, 893, 899998,"18446743999999999999", 3778888999, "277777788888899"
}
local test_fmt = "%20s %3s %3s"
fmt.print(test_fmt, "Number", "MDR", "MP")
for tests as test do
local n = bigint.new(test)
local mpdr = mult_digital_root(n, base)
fmt.print(test_fmt, n, mpdr[2], mpdr[1])
end
print()
local list = table.create(base)
for i = 1, base do list[i] = {} end
local cnt = size * base
local n = zero
while cnt > 0 do
local mpdr = mult_digital_root(n, base)
local mdr = mpdr[2]
if #list[mdr + 1] < size then
list[mdr + 1]:insert(n)
cnt -= 1
end
n += one
end
fmt.print("%3s: %s", "MDR", "First")
local i = 0
for list as l do
fmt.print("%3d: %,s", i, l)
i += 1
end

View file

@ -0,0 +1,36 @@
numdigits <- function(n) ifelse(log10(n)%%1==0,
1+log10(n),
ceiling(log10(n)))
digmul <- function(n){
k <- numdigits(n)
get_digit <- function(m) (n%/%10^m)%%10
prod(sapply(0:(k-1), get_digit))
}
mdr_mp <- function(n){
m <- n
i <- 0
while(m > 9){
m <- digmul(m)
i <- i+1
}
c("MDR"=m, "MP"=i)
}
test_nums <- c(123321, 7739, 893, 899998)
rbind("n"=test_nums, sapply(test_nums, mdr_mp)) |> t()
first5mdr <- function(n){
m <- 0
nums <- numeric(0)
while(length(nums) < 5){
if(mdr_mp(m)[1] == n){
nums <- c(nums, m)
}
m <- m+1
}
setNames(nums, paste0("n_", 1:5))
}
rbind("MDR"=0:9, sapply(0:9, first5mdr)) |> t()