Triangular numbers: Difference between revisions
Content added Content deleted
Thundergnat (talk | contribs) m (Add another related task) |
Thundergnat (talk | contribs) m (→{{header|Raku}}: reformat slightly) |
||
Line 81: | Line 81: | ||
sub polytopic (Int $r, @range) { @range.map: { binomial $_ + $r - 1, $r } } |
sub polytopic (Int $r, @range) { @range.map: { binomial $_ + $r - 1, $r } } |
||
sub triangular-root ($x) { |
sub triangular-root ($x) { round ((8 × $x + 1).&root - 1) / 2, ε } |
||
sub tetrahedral-root ($x) { |
sub tetrahedral-root ($x) { |
||
Line 88: | Line 88: | ||
} |
} |
||
sub pentatopic-root ($x) { |
sub pentatopic-root ($x) { round ((5 + 4 × (24 × $x + 1).&root).&root - 3) / 2, ε } |
||
sub display (@values) { |
sub display (@values) { |
||
Line 95: | Line 95: | ||
} |
} |
||
for 2, 'triangular', 3, 'tetrahedral', |
for 2, 'triangular', 3, 'tetrahedral', 4, 'pentatopic', 12, '12-simplex' |
||
⚫ | |||
4, 'pentatopic', 12, '12-simplex' |
|||
-> $r, $name { |
|||
⚫ | |||
display polytopic( $r, ^Inf )[^30] |
|||
} |
|||
say ''; |
say ''; |