(48G) Number of Perfect Integer Partitions (also 49G & 50G)
07-05-2015, 06:29 PM (This post was last modified: 06-15-2017 01:50 PM by Gene.)
Post: #1
 Gerald H Senior Member Posts: 1,522 Joined: May 2014
(48G) Number of Perfect Integer Partitions (also 49G & 50G)
For positive integer input the programme returns the number of perfect partitions.

A perfect partition of N allows additive composition of all numbers <= N.

eg

{4 , 1} is not a perfect partition of 5 as you can't make 2 from a sum of the elements.

{1 , 2 , 2} is a perfect partition of 5 as all of 1, 2, 3, 4 & 5 are additively composable from its elements.

Code:
 ::   CK1&Dispatch   BINT1   ::     DUP     %0<     caseSIZEERR     %IP     COERCE     #1+     BINT1     OVER     NDUPN     '     NULLLAM     SWAP     NDUPN     DOBIND     DUP#1+     BINT2     DO     BINT0     INDEX@     DUP     ONE_DO     DUPINDEX@     #/     DROP     #0=     IT     ::       SWAPINDEX@       GETLAM       #+SWAP     ;     LOOP     PUTLAM     LOOP     GETLAM     ABND     UNCOERCE   ; ;
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)