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,20 @@
def do_until(condition; next):
def u: if condition then . else (next|u) end;
u;
# n may be a decimal number or a string representing a decimal number
def digital_root(n):
# string-only version
def dr:
# state: [mdr, persist]
do_until( .[0] | length == 1;
[ (.[0] | explode | map(.-48) | add | tostring), .[1] + 1 ]
);
[n|tostring, 0] | dr | .[0] |= tonumber;
def neatly:
. as $in
| range(0;length)
| "\(.): \($in[.])";
def rjust(n): tostring | (n-length)*" " + .;

View file

@ -0,0 +1,8 @@
(
" i : [DR, P]",
(961038, 923594037444, 670033, 448944221089
) as $i
| "\($i|rjust(12)): \(digital_root($i))"
),
"",
"digital_root(\"1\" * 100000) => \(digital_root( "1" * 100000))"

View file

@ -0,0 +1,9 @@
$ jq -M -n -r -c -f Digital_root.jq
i : [DR, P]
961038: [9,2]
923594037444: [9,2]
670033: [1,3]
448944221089: [1,3]
digital_root("1" * 100000) => [1,2]