Multifactorial: Difference between revisions
Content added Content deleted
(→{{header|ANSI Standard BASIC}}: Changed to {{header|ANSI BASIC}}; {{works with|Decimal BASIC}}; output.) |
imported>Maxima enthusiast No edit summary |
||
Line 1,437: | Line 1,437: | ||
4: 1 2 3 4 5 12 21 32 45 120 |
4: 1 2 3 4 5 12 21 32 45 120 |
||
5: 1 2 3 4 5 6 14 24 36 50</pre> |
5: 1 2 3 4 5 6 14 24 36 50</pre> |
||
=={{header|Maxima}}== |
|||
Using built-in function genfact |
|||
<syntaxhighlight lang="maxima"> |
|||
multifactorial(x,n):=genfact(x,x/n,n)$ |
|||
/* Test case */ |
|||
makelist(multifactorial(i,1),i,1,10); |
|||
makelist(multifactorial(i,2),i,1,10); |
|||
block(makelist(mod(i,3),i,1,10),at(%%,0=1),%%*makelist(multifactorial(i,3),i,1,10)); |
|||
block(makelist(mod(i,4),i,1,10),at(%%,0=1),%%*makelist(multifactorial(i,4),i,1,10)); |
|||
block(makelist(mod(i,5),i,1,10),at(%%,0=1),%%*makelist(multifactorial(i,5),i,1,10)); |
|||
</syntaxhighlight> |
|||
{{out}} |
|||
<pre> |
|||
[1,2,6,24,120,720,5040,40320,362880,3628800] |
|||
[1,2,3,8,15,48,105,384,945,3840] |
|||
[1,2,3,4,10,18,28,80,162,280] |
|||
[1,2,3,4,5,12,21,32,45,120] |
|||
[1,2,3,4,5,6,14,24,36,50] |
|||
</pre> |
|||
=={{header|min}}== |
=={{header|min}}== |