Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Partition-function-P/REXX/partition-function-p-1.rexx
Normal file
31
Task/Partition-function-P/REXX/partition-function-p-1.rexx
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
/*REXX program calculates and displays a specific value (or a range of) partitionsP(N).*/
|
||||
numeric digits 1000 /*able to handle some ginormous numbers*/
|
||||
parse arg lo hi . /*obtain optional arguments from the CL*/
|
||||
if lo=='' | lo=="," then lo= 0 /*Not specified? Then use the default.*/
|
||||
if hi=='' | hi=="," then hi= lo /* " " " " " " */
|
||||
@.= 0; @.0= 1; @.1= 1; @.2= 2; @.3= 3; @.4= 5 /*assign default value and low values. */
|
||||
!.= @.; !.1= 1; !.3= 1; !.5= 1; !.7= 1; !.9= 1 /*assign default value and even digits.*/
|
||||
w= length( commas(hi) ) /*W: is used for aligning the index. */
|
||||
|
||||
do j=lo to hi /*compute a range of partitionsP. */
|
||||
say right( commas(j), w) ' ' commas( partP(j) )
|
||||
end /*j*/
|
||||
exit 0 /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
partP: procedure expose @. !.; parse arg n /*obtain number (index) for computation*/
|
||||
if @.n\==0 then return @.n /*Is it already computed? Return it. */
|
||||
#= 0 /*initialize part P number.*/
|
||||
do k=1 for n; z= n - (k*3 - 1) * k % 2 /*compute the partition P num*/
|
||||
if z<0 then leave /*Is Z negative? Then leave.*/
|
||||
if @.z==0 then x= partP(z) /*use recursion if not known.*/
|
||||
else x= @.z /*use the pre─computed number*/
|
||||
z= z - k /*subtract index (K) from Z. */
|
||||
if z<0 then y= 0 /*Is Z negative? Then set Y=0*/
|
||||
else if @.z==0 then y= partP(z) /*use recursion if not known.*/
|
||||
else y= @.z /*use the pre─computed number*/
|
||||
if k//2 then #= # + x + y /*Odd? Then sum X and Y.*/
|
||||
else #= # - (x + y) /*Even? " subtract " " " */
|
||||
end /*k*/
|
||||
@.n= #; return # /*define and return partitionsP of N. */
|
||||
32
Task/Partition-function-P/REXX/partition-function-p-2.rexx
Normal file
32
Task/Partition-function-P/REXX/partition-function-p-2.rexx
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/*REXX program calculates and displays a specific value (or a range of) partitionsP(N).*/
|
||||
numeric digits 1000 /*able to handle some ginormous numbers*/
|
||||
parse arg lo hi . /*obtain optional arguments from the CL*/
|
||||
if lo=='' | lo=="," then lo= 0 /*Not specified? Then use the default.*/
|
||||
if hi=='' | hi=="," then hi= lo /* " " " " " " */
|
||||
@.= 0; @.0= 1; @.1= 1; @.2= 2; @.3= 3; @.4= 5 /*default values for some low numbers. */
|
||||
!.= @.; !.1= 1; !.3= 1; !.5= 1; !.7= 1; !.9= 1 /* " " " all the 1─digit #s*/
|
||||
w= length( commas(hi) ) /*W: is used for aligning the index. */
|
||||
|
||||
do j=lo to hi /*compute a range of partitionsP. */
|
||||
say right( commas(j), w) ' ' commas( partP(j) )
|
||||
end /*j*/
|
||||
exit 0 /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
partP: procedure expose @. !.; parse arg n /*obtain number (index) for computation*/
|
||||
if @.n\==0 then return @.n /*Is it already computed? Return it. */
|
||||
#= 0 /*initialize part P number.*/
|
||||
do k=1 for n; z= n - (k+k+k - 1) * k % 2 /*compute the partition P num*/
|
||||
if z<0 then leave /*Is Z negative? Then leave.*/
|
||||
if @.z==0 then x= partP(z) /*use recursion if not known.*/
|
||||
else x= @.z /*use the pre─computed number*/
|
||||
z= z - k /*subtract index (K) from Z. */
|
||||
if z<0 then y= 0 /*Is Z negative? Then set Y=0*/
|
||||
else if @.z==0 then y= partP(z) /*use recursion if not known.*/
|
||||
else y= @.z /*use the pre─computed number*/
|
||||
parse var k '' -1 _ /*obtain K's last decimal dig*/
|
||||
if !._ then #= # + x + y /*Odd? Then sum X and Y.*/
|
||||
else #= # - (x + y) /*Even? " subtract " " " */
|
||||
end /*k*/
|
||||
@.n= #; return # /*define and return partitionsP of N. */
|
||||
34
Task/Partition-function-P/REXX/partition-function-p-3.rexx
Normal file
34
Task/Partition-function-P/REXX/partition-function-p-3.rexx
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
/*REXX program calculates and displays a specific value (or a range of) partitionsP(N).*/
|
||||
numeric digits 1000 /*able to handle some ginormous numbers*/
|
||||
parse arg lo hi . /*obtain optional arguments from the CL*/
|
||||
if lo=='' | lo=="," then lo= 0 /*Not specified? Then use the default.*/
|
||||
if hi=='' | hi=="," then hi= lo /* " " " " " " */
|
||||
@.= 0; @.0= 1; @.1= 1; @.2= 2; @.3= 3; @.4= 5 /*default values for some low numbers. */
|
||||
!.= @.; !.1= 1; !.3= 1; !.5= 1; !.7= 1; !.9= 1 /* " " " all the 1─digit #s*/
|
||||
w= length( commas(hi) ) /*W: is used for aligning the index. */
|
||||
do i=1 for hi; a.i= (i+i+i - 1) * i % 2 /*calculate HI expressions (for partP).*/
|
||||
end /*i*/
|
||||
|
||||
do j=lo to hi /*compute a range of partitionsP. */
|
||||
say right( commas(j), w) ' ' commas( partP(j) )
|
||||
end /*j*/
|
||||
exit 0 /*stick a fork in it, we're all done. */
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
commas: parse arg ?; do jc=length(?)-3 to 1 by -3; ?=insert(',', ?, jc); end; return ?
|
||||
/*──────────────────────────────────────────────────────────────────────────────────────*/
|
||||
partP: procedure expose @. !. a.; parse arg n /*obtain number (index) for computation*/
|
||||
if @.n\==0 then return @.n /*Is it already computed? Return it. */
|
||||
#= 0 /*initialize part P number.*/
|
||||
do k=1 for n; z= n - a.k /*compute the partition P num*/
|
||||
if z<0 then leave /*Is Z negative? Then leave.*/
|
||||
if @.z==0 then x= partP(z) /*use recursion if not known.*/
|
||||
else x= @.z /*use the pre─computed number*/
|
||||
z= z - k /*subtract index (K) from Z. */
|
||||
if z<0 then y= 0 /*Is Z negative? Then set Y=0*/
|
||||
else if @.z==0 then y= partP(z) /*use recursion if not known.*/
|
||||
else y= @.z /*use the pre─computed number*/
|
||||
parse var k '' -1 _ /*obtain K's last decimal dig*/
|
||||
if !._ then #= # + x + y /*Odd? Then sum X and Y.*/
|
||||
else #= # - (x + y) /*Even? " subtract " " " */
|
||||
end /*k*/
|
||||
@.n= #; return # /*define and return partitionsP of N. */
|
||||
Loading…
Add table
Add a link
Reference in a new issue