Data update

This commit is contained in:
Ingy döt Net 2026-02-01 16:33:20 -08:00
parent 5150844a7d
commit 4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions

View file

@ -1,76 +0,0 @@
-- Rosetta Code Task written in Ada
-- Left factorials
-- https://rosettacode.org/wiki/Left_factorials
-- (Mostly) translated from the AWK example
-- February 2025, R. B. E.
-- Using PragmARC.Unbounded_Numbers, GNAT version 14.2.0-3, MacOS 15.3, M1 chip
with Ada.Text_IO; use Ada.Text_IO;
with Ada.Integer_Text_IO; use Ada.Integer_Text_IO;
with PragmARC.Unbounded_Numbers.Integers; use PragmARC.Unbounded_Numbers.Integers;
procedure Left_Factorials is
function Left_Fact (F : Natural) return Unbounded_Integer is
Result : Unbounded_Integer := To_Unbounded_Integer (0);
Adder : Unbounded_Integer := To_Unbounded_Integer (1);
begin
if F = 0 then
return Result;
end if;
for K in 1..F loop
Result := Result + Adder;
Adder := Adder * To_Unbounded_Integer (K);
end loop;
return Result;
end Left_Fact;
function Brute_Force_Digit_String_Length (N : in Unbounded_Integer) return Natural is
Big_Zero : constant Unbounded_Integer := To_Unbounded_Integer (0);
Big_Ten : constant Unbounded_Integer := To_Unbounded_Integer (10);
Local_N : Unbounded_Integer := N;
String_Length : Natural := 0;
begin
loop
exit when Local_N = Big_Zero;
Local_N := Local_N / Big_Ten;
String_Length := String_Length + 1;
end loop;
return String_Length;
end Brute_Force_Digit_String_Length;
begin
for I in 0..10 loop
Put ("!");
Put (I, 0);
Put (" = ");
Put (Image (Value => Left_Fact (I)));
New_Line;
end loop;
New_Line;
for I in 20..110 loop
if (I mod 10) = 0 then
Put ("!");
Put (I, 0);
Put (" =");
if I < 70 then
Put (" ");
else
New_Line;
end if;
Put (Image (Value => Left_Fact (I)));
New_Line;
end if;
end loop;
New_Line;
for I in 1_000..10_000 loop
if (I mod 1_000) = 0 then
Put ("!");
Put (I, 0);
Put (" has ");
Put (Brute_Force_Digit_String_Length (Left_Fact (I)), 0);
Put_Line (" digits.");
end if;
end loop;
New_Line;
end Left_Factorials;

View file

@ -1,26 +0,0 @@
function left-factorial ([BigInt]$n) {
[BigInt]$k, [BigInt]$fact = ([BigInt]::Zero), ([BigInt]::One)
[BigInt]$lfact = ([BigInt]::Zero)
while($k -lt $n){
if($k -gt ([BigInt]::Zero)) {
$fact = [BigInt]::Multiply($fact, $k)
$lfact = [BigInt]::Add($lfact, $fact)
} else {
$lfact = ([BigInt]::One)
}
$k = [BigInt]::Add($k, [BigInt]::One)
}
$lfact
}
0..9 | foreach{
"!$_ = $(left-factorial $_)"
}
for($i = 10; $i -le 110; $i += 10) {
"!$i = $(left-factorial $i)"
}
for($i = 1000; $i -le 10000; $i += 1000) {
$digits = [BigInt]::Log10($(left-factorial $i))
$digits = [Math]::Floor($digits) + 1
if($digits -gt 1) {"!$i has $digits digits"}
else {"!$i has $digits digit"}
}