HP Forums
(50G)Integer Partitions in Fibonacci Numbers - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Software Libraries (/forum-10.html)
+--- Forum: General Software Library (/forum-13.html)
+--- Thread: (50G)Integer Partitions in Fibonacci Numbers (/thread-4516.html)



(50G)Integer Partitions in Fibonacci Numbers - Gerald H - 08-12-2015 02:34 PM

The total number of partitions of

7

is

15

of which

10

are composed purely of Fibonacci numbers &

1

is composed of distinct Fibonacci numbers.

{ [ 7 ] [ 6 1 ] [ 5 2 ] [ 5 1 1 ] [ 4 3 ] [ 4 2 1 ] [ 4 1 1 1 ] [ 3 3 1 ] [ 3 2 2 ] [ 3 2 1 1 ] [ 3 1 1 1 1 ] [ 2 2 2 1 ] [ 2 2 1 1 1 ] [ 2 1 1 1 1 1 ] [ 1 1 1 1 1 1 1 ] }

The programme PINFIBS returns for integer input the number of partitions in Fibonacci numbers.

Code:

PINFIBS

::
  CK1&Dispatch
  BINT1
  ::
    "       # PARTITIONS IN FIBOS"
    DispCoord1
    SetDA3Temp
    %ABSCOERCE
    ONEONE
    '
    ::
      3PICK3PICK
      #<
      case2drop
      ::
        #0=case
        BINT1
        BINT0
      ;
      3PICK3PICK
      #-
      3PICK3PICK
      1GETLAM
      EVAL
      4UNROLL
      OVER
      #+SWAP
      1GETLAM
      EVAL
      #+
    ;
    DUP1LAMBIND
    EVAL
    ABND
    FPTR2 ^#>Z
  ;
;

The programme PINDFIBS returns for integer input the number of partitions in distinct Fibonacci numbers.

Code:

PINDFIBS

::
  CK1&Dispatch
  BINT1
  ::
    "  # PARTITIONS IN DISTINCT FIBOS"
    DispCoord1
    SetDA3Temp
    %ABSCOERCE
    ONEONE
    '
    ::
      3PICK3PICK
      #<
      case2drop
      ::
        #0=case
        BINT1
        BINT0
      ;
      3PICK3PICK
      #-
      3PICK3PICK
      OVER
      #+SWAP
      1GETLAM
      EVAL
      4UNROLL
      OVER
      #+SWAP
      1GETLAM
      EVAL
      #+
    ;
    DUP1LAMBIND
    EVAL
    ABND
    FPTR2 ^#>Z
  ;
;