Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,69 +0,0 @@
|
|||
pragma Ada_2022;
|
||||
with Ada.Text_IO; use Ada.Text_IO;
|
||||
with Ada.Numerics.Big_Numbers.Big_Integers;
|
||||
use Ada.Numerics.Big_Numbers.Big_Integers;
|
||||
with Interfaces; use Interfaces;
|
||||
|
||||
procedure Combs_Perms is
|
||||
|
||||
function U64_Perm (N, K : Unsigned_64) return Unsigned_64 is
|
||||
P : Unsigned_64 := 1;
|
||||
begin
|
||||
if K = 0 then
|
||||
P := 0;
|
||||
else
|
||||
for I in 0 .. K - 1 loop
|
||||
P := P * (N - I);
|
||||
end loop;
|
||||
end if;
|
||||
return P;
|
||||
end U64_Perm;
|
||||
|
||||
function Big_Perm (N, K : Natural) return Big_Natural is
|
||||
P : Big_Natural := 1;
|
||||
begin
|
||||
if K = 0 then
|
||||
P := 0;
|
||||
else
|
||||
for I in 0 .. K - 1 loop
|
||||
P := P * To_Big_Integer (N - I);
|
||||
end loop;
|
||||
end if;
|
||||
return P;
|
||||
end Big_Perm;
|
||||
|
||||
function U64_Comb (N, K : Unsigned_64) return Unsigned_64 is
|
||||
Adj_K : constant Unsigned_64 := (if N - K < K then N - K else K);
|
||||
C : Unsigned_64 := U64_Perm (N, Adj_K);
|
||||
begin
|
||||
if K = 0 then
|
||||
C := 0;
|
||||
else
|
||||
for I in reverse 1 .. Adj_K loop
|
||||
C := C / I;
|
||||
end loop;
|
||||
end if;
|
||||
return C;
|
||||
end U64_Comb;
|
||||
|
||||
function Big_Comb (N, K : Natural) return Big_Natural is
|
||||
Adj_K : constant Natural := (if N - K < K then N - K else K);
|
||||
C : Big_Natural := Big_Perm (N, Adj_K);
|
||||
begin
|
||||
for I in reverse 1 .. Adj_K loop
|
||||
C := C / To_Big_Integer (I);
|
||||
end loop;
|
||||
return C;
|
||||
end Big_Comb;
|
||||
|
||||
begin
|
||||
Put_Line ("P(1, 0) =" & U64_Perm (1, 0)'Image);
|
||||
Put_Line ("P(12, 4) =" & U64_Perm (12, 4)'Image);
|
||||
Put_Line ("P(60, 20) =" & U64_Perm (60, 20)'Image);
|
||||
Put_Line ("P(105, 103) =" & Big_Perm (105, 103)'Image);
|
||||
Put_Line ("P(15000, 333) =" & Big_Perm (10000, 333)'Image);
|
||||
|
||||
Put_Line ("C(10, 5) =" & U64_Comb (10, 5)'Image);
|
||||
Put_Line ("C(60, 30) =" & Big_Comb (60, 30)'Image);
|
||||
Put_Line ("C(900, 674) =" & Big_Comb (900, 674)'Image);
|
||||
end Combs_Perms;
|
||||
|
|
@ -1,37 +1,31 @@
|
|||
func perm x y .
|
||||
z = 1
|
||||
for i = x - y + 1 to x
|
||||
z *= i
|
||||
.
|
||||
for i = x - y + 1 to x : z *= i
|
||||
return z
|
||||
.
|
||||
func fact x .
|
||||
z = 1
|
||||
for i = 2 to x
|
||||
z *= i
|
||||
.
|
||||
for i = 2 to x : z *= i
|
||||
return z
|
||||
.
|
||||
func comb x y .
|
||||
if x - y < y
|
||||
y = x - y
|
||||
.
|
||||
if x - y < y : y = x - y
|
||||
return perm x y / fact y
|
||||
.
|
||||
#
|
||||
e = 2.7182818284590452354
|
||||
func log n .
|
||||
return log10 n / log10 e
|
||||
func logn n .
|
||||
return log n 0
|
||||
.
|
||||
func lstirling n .
|
||||
if n < 10
|
||||
return lstirling (n + 1) - log (n + 1)
|
||||
return lstirling (n + 1) - logn (n + 1)
|
||||
.
|
||||
return 0.5 * log (2 * pi * n) + n * log (n / e + 1 / (12 * e * n))
|
||||
return 0.5 * logn (2 * pi * n) + n * logn (n / e + 1 / (12 * e * n))
|
||||
.
|
||||
func$ tolog v .
|
||||
h = v div log 10
|
||||
return pow e (v - h * log 10) & "e" & h
|
||||
h = v div logn 10
|
||||
return pow e (v - h * logn 10) & "e" & h
|
||||
.
|
||||
func$ permf n k .
|
||||
return tolog (lstirling n - lstirling (n - k))
|
||||
|
|
|
|||
|
|
@ -1,59 +0,0 @@
|
|||
' Combinations and permutations - vbs - 10/04/2017
|
||||
dim i,j
|
||||
Wscript.StdOut.WriteLine "-- Long Integer - Permutations - from 1 to 12"
|
||||
for i=1 to 12
|
||||
for j=1 to i
|
||||
Wscript.StdOut.Write "P(" & i & "," & j & ")=" & perm(i,j) & " "
|
||||
next 'j
|
||||
Wscript.StdOut.WriteLine ""
|
||||
next 'i
|
||||
Wscript.StdOut.WriteLine "-- Float integer - Combinations from 10 to 60"
|
||||
for i=10 to 60 step 10
|
||||
for j=1 to i step i\5
|
||||
Wscript.StdOut.Write "C(" & i & "," & j & ")=" & comb(i,j) & " "
|
||||
next 'j
|
||||
Wscript.StdOut.WriteLine ""
|
||||
next 'i
|
||||
Wscript.StdOut.WriteLine "-- Float integer - Permutations from 5000 to 15000"
|
||||
for i=5000 to 15000 step 5000
|
||||
for j=10 to 70 step 20
|
||||
Wscript.StdOut.Write "C(" & i & "," & j & ")=" & perm(i,j) & " "
|
||||
next 'j
|
||||
Wscript.StdOut.WriteLine ""
|
||||
next 'i
|
||||
Wscript.StdOut.WriteLine "-- Float integer - Combinations from 200 to 1000"
|
||||
for i=200 to 1000 step 200
|
||||
for j=20 to 100 step 20
|
||||
Wscript.StdOut.Write "P(" & i & "," & j & ")=" & comb(i,j) & " "
|
||||
next 'j
|
||||
Wscript.StdOut.WriteLine ""
|
||||
next 'i
|
||||
|
||||
function perm(x,y)
|
||||
dim i,z
|
||||
z=1
|
||||
for i=x-y+1 to x
|
||||
z=z*i
|
||||
next 'i
|
||||
perm=z
|
||||
end function 'perm
|
||||
|
||||
function fact(x)
|
||||
dim i,z
|
||||
z=1
|
||||
for i=2 to x
|
||||
z=z*i
|
||||
next 'i
|
||||
fact=z
|
||||
end function 'fact
|
||||
|
||||
function comb(byval x,byval y)
|
||||
if y>x then
|
||||
comb=0
|
||||
elseif x=y then
|
||||
comb=1
|
||||
else
|
||||
if x-y<y then y=x-y
|
||||
comb=perm(x,y)/fact(y)
|
||||
end if
|
||||
end function 'comb
|
||||
Loading…
Add table
Add a link
Reference in a new issue