Data commit

This commit is contained in:
Ingy döt Net 2023-07-01 11:58:00 -04:00
parent 7387c8f97b
commit cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions

View file

@ -0,0 +1,23 @@
sub digital-root ($r, :$base = 10) {
my $root = $r.base($base);
my $persistence = 0;
while $root.chars > 1 {
$root = $root.comb.map({:36($_)}).sum.base($base);
$persistence++;
}
$root, $persistence;
}
my @testnums =
627615,
39390,
588225,
393900588225,
58142718981673030403681039458302204471300738980834668522257090844071443085937;
for 10, 8, 16, 36 -> $b {
for @testnums -> $n {
printf ":$b\<%s>\ndigital root %s, persistence %s\n\n",
$n.base($b), digital-root $n, :base($b);
}
}

View file

@ -0,0 +1,6 @@
sub digital-root ($r, :$base = 10) {
my &sum = { .comb.map({:36($_)}).sum.base($base) }
return .[*-1], .elems-1
given $r.base($base), &sum { .chars == 1 }
}