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,38 @@
include "cowgol.coh";
# Calculate the digital root and additive persistance of a number
# in a given base
sub digital_root(n: uint32, base: uint32): (root: uint32, pers: uint8) is
pers := 0;
while base < n loop
var step: uint32 := 0;
while n > 0 loop
step := step + (n % base);
n := n / base;
end loop;
pers := pers + 1;
n := step;
end loop;
root := n;
end sub;
# Print digital root and persistence (in base 10)
sub test(n: uint32) is
var root: uint32;
var pers: uint8;
(root, pers) := digital_root(n, 10);
print_i32(n);
print(": root = ");
print_i32(root);
print(", persistence = ");
print_i8(pers);
print_nl();
end sub;
test(4);
test(627615);
test(39390);
test(588225);
test(9992);