Is this of any help?

$n\$d 1 2 3 4 5 6 7 1 1 1 1 1 1 1 1 2 4 5 6 7 8 9 10 3 10 15 21 28 36 45 55 4 20 35 56 84 120 165 220 5 35 70 126 210 330 495 715 6 56 126 252 462 792 1287 2002 7 84 210 462 924 1716 3003 5005 8 120 330 792 1716 3432 6435 11440 9 165 495 1287 3003 6435 12870 24310 10 220 715 2002 5005 11440 24310 48620 11 286 1001 3003 8008 19448 43758 92378 12 364 1365 4368 12376 31824 75582 167960 13 455 1820 6188 18564 50388 125970 293930 14 560 2380 8568 27132 77520 203490 497420 15 680 3060 11628 38760 116280 319770 817190 16 816 3876 15504 54264 170544 490314 1307504 17 969 4845 20349 74613 245157 735471 2042975 18 1140 5985 26334 100947 346104 1081575 3124550 19 1330 7315 33649 134596 480700 1562275 4686825 20 1540 8855 42504 177100 657800 2220075 6906900

The above was produced using the following program:

use strict; use warnings; use List::Util qw( sum ); { my %memoize; sub calcIt { my ($n, $d) = @_; return $memoize{"$n:$d"} ||= ( ($d ? sum map { calcIt($_, $d-1) } 1..$n : $n * ( $n + 1 ) / 2 ) ); } } { my $N = 20; my $D = 7; print('$n\\$d'); for my $d (1..$D) { print("\t$d"); } print("\n"); for my $n (1..$N) { print("$n"); for my $d (1..$D) { print("\t", calcIt($n, $d)); } print("\n"); } }

You can really appreciate the effect of memoization here.


In reply to Re: Math fun. by ikegami
in thread Math fun. by BrowserUk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.