The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(50g) Delannoy numbers
06-02-2019, 11:34 PM (This post was last modified: 06-02-2019 11:38 PM by John Keith.)
Post: #1
(50g) Delannoy numbers
Delannoy numbers have many applications in combinatorics and number theory. Fortunately they are fast and easy to compute. Further details here.

The following program returns a rectangular array of Delannoy numbers. Given two integers referred to as m and n in the linked article, the program will return an array of m columns and n rows. The program actually returns a list of lists, and may be followed by AXL if a matrix is desired. The program requires the GoferLists library.

Code:

\<< \-> m n
  \<< 1 m NDUPN \->LIST 2 n
    START DUP 2.
      \<< +
      \>> DOSUBS 1
      \<< +
      \>> Scanl
    NEXT n \->LIST
  \>>
\>>

The next program returns the Delannoy triangle, also known as the tribonacci triangle. The numbers are the same as in the array but arranged in a triangle. Given an integer n, the program returns rows 0 through n of the triangle as a list of lists.

Code:

\<< \-> n
  \<< { 1 } DUP 1 + 2 n
    START DUP2 2.
      \<< +
      \>> DOSUBS ADD 1 + 1 SWAP +
    NEXT n 1 + \->LIST
  \>>
\>>

Finally, a program that computes the central Delannoy numbers which are the central column of the triangle and the main diagonal of the array. Given an integer n the program returns terms 0 through n of the sequence.

Code:

\<< \-> n
  \<< 1 3 2 n
    FOR k DUP2 k 6 * 3 - * SWAP k 1 - * - k /
    NEXT n 1 + \->LIST
  \>>
\>>

The last two programs will run on the HP-48G but are of limited usefulness since the numbers involved grow rapidly beyond 12 digits.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(50g) Delannoy numbers - John Keith - 06-02-2019 11:34 PM
RE: (50g) Delannoy numbers - Luigi Vampa - 06-03-2019, 06:52 PM



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