Data update

This commit is contained in:
Ingy döt Net 2025-02-27 18:35:13 -05:00
parent 8e4e15fa56
commit 72eb4943cb
1853 changed files with 35514 additions and 9441 deletions

View file

@ -0,0 +1,46 @@
BEGIN # calculate the partition function of some integers #
# translated from the FreeBASIC sample #
PR precision 128 PR # set the number of digits for LONG LONG INT #
MODE PARTINT = LONG LONG INT;
PROC partitions p = ( INT n )PARTINT:
BEGIN
[ 0 : n ]PARTINT p; FOR i FROM LWB p TO UPB p DO p[ i ] := 0 OD;
p[ 0 ] := 1;
FOR i TO n DO
INT k := 0;
WHILE k +:= 1;
INT j := ( k * ( 3 * k - 1 ) ) OVER 2;
IF j > i
THEN FALSE # exit the loop #
ELSE IF ODD k THEN
p[ i ] +:= p[ i - j ]
ELSE
p[ i ] -:= p[ i - j ]
FI;
j +:= k;
IF j > i
THEN FALSE # exit the loop #
ELSE IF ODD k THEN
p[ i ] +:= p[ i - j ]
ELSE
p[ i ] -:= p[ i - j ]
FI;
TRUE # continue to loop #
FI
FI
DO SKIP OD
OD;
p[ n ]
END # partitions p # ;
BEGIN
print( ( "P(0..12):" ) );
FOR x FROM 0 TO 12 DO
print( ( " ", whole( partitions p( x ), 0 ) ) )
OD;
print( ( newline, "P(127): ", whole( partitions p( 127 ), 0 ) ) );
print( ( newline, "P(255): ", whole( partitions p( 255 ), 0 ) ) );
print( ( newline, "P(6666): ", whole( partitions p( 6666 ), 0 ) ) );
print( ( newline ) )
END
END

View file

@ -0,0 +1,2 @@
part = 1 : b 1
where b n = p where p = zipWith (+) (1 : b (n + 1)) (replicate n 0 ++ p)

View file

@ -0,0 +1,6 @@
ghci> take 30 part
[1,1,2,3,5,7,11,15,22,30,42,56,77,101,135,176,231,297,385,490,627,792,1002,1255,1575,1958,2436,3010,3718,4565]
ghci> :set +s
ghci> part !! 6666
193655306161707661080005073394486091998480950338405932486880600467114423441282418165863
(4.89 secs, 5,214,048,336 bytes)

View file

@ -0,0 +1 @@
{{ {: (y{. +//.@(*/) )/ (0=}.|/])@i. @ >:y}}

View file

@ -0,0 +1,2 @@
{{ {: (y{. +//.@(*/) )/ (x:(0=}.|/])@i. @ >:y)}} 666
11393868451739000294452939

View file

@ -0,0 +1,36 @@
program partition_function;
loop for n in [666, 6666] do
show_partition_with_time(n);
end loop;
proc show_partition_with_time(n);
s := clock;
p := partition(n);
d := (clock - s) / 1000;
print("p(" + str n + ") = " + str p + " (" + str d + "s)");
end proc;
proc partition(n);
pn := [1,1];
loop for i in [3..n+2] do
pn(i) := 0;
loop init k := 1; step k +:= 1; do
penta := k * (3 * k-1) div 2;
if penta >= i-1 then quit; end if;
if k mod 2 = 1 then
pn(i) +:= pn(i-penta);
else
pn(i) -:= pn(i-penta);
end if;
penta +:= k;
if penta >= i-1 then quit; end if;
if k mod 2 = 1 then
pn(i) +:= pn(i-penta);
else
pn(i) -:= pn(i-penta);
end if;
end loop;
end loop;
return pn(n+2);
end proc;
end program;