(N.B.  I hate it when this is done, but... sadly this page will not work on ye olde browsres, as it requires superscript and subscript.  Any modern browser should be able to cope, however.)

The Pyramid Numbers

I’ve recently been working with what I, for want of a better name, call the “pyramid numbers”.  I’ve been writing a Poker-hand evaluation routine, and thus needed to encode a unique number for all combinations of n (=2, 3 or 5) items from 13 (the items being numbered 0 to 12), such that the bigger the numbers involved, the bigger the result.  It turned out that C(2,a,b)=a+P(2,b-1) (where C(n,a,b...) is the unique code number required for a combination in the domain kCn and a, b etc. are the elements of that combination (in ascending order, a=smallest); as for P(p,n), read on!); C(3,a,b,c)=C(2,a,b)+P(3,c-2); C(4,a,b,c,d)=C(3,a,b,c)+P(4,d-3); etc.

So, what is a Pyramid Number?

Good point.  Definitions:
P(p,0)=0 for any p.
P(0,n)=1 for any positive-integer (i.e. nonzero) n.
P(p,n)=the sum (for k=1 to n) of all P(p-1,k), p and n both being positive integers.

Of course, it would be hopelessly inefficient to actually calculate them (especially the larger or higher-order ones) that way.  Fortunately, it is easy to derive a few formulae:

P(1,n)=n
P(2,n)=(n2+n)/2 (the well-known “triangle” numbers — hence “pyramid” for the general case).
P(3,n)=(n3+3n2+2n)/6
P(4,n)=(n4+6n3+11n2+6n)/24
P(5,n)=(n5+10n4+35n3+50n2+24n)/120

When the first few values of P(p,n) (starting from P(0,1)) are set out in a neat table, they can be seen to form a Pascal’s Triangle rotated 45° anti-clockwise.  Interesting...

Made with 1st Page
2000 — Professional tools for real minds.