Multifactorial: Difference between revisions
→Sequence solution: Clean-up.
ReeceGoding (talk | contribs) m (→{{header|R}}: Syntax highlighting.) |
ReeceGoding (talk | contribs) (→Sequence solution: Clean-up.) |
||
Line 1,672:
===Sequence solution===
This task doesn't use big enough numbers to need efficient code, so R can solve this very succinctly.
<lang rsplus>
cat("Simple version:\n")
print(outer(1:10, 1:5, Vectorize(
If we really insist on a pretty table, then we can add some names and transpose the output.
<lang rsplus>
print(t(outer(setNames(1:10, 1:10), setNames(1:5, paste0("Degree ", 1:5, ":")), Vectorize(mFact))))</lang>
{{out}}
<pre>Simple version:
[,1] [,2] [,3] [,4] [,5]
[1,] 1 1 1 1 1
Line 1,692:
[9,] 362880 945 162 45 36
[10,] 3628800 3840 280 120 50
Pretty version:
▲#"Pretty" version:
Degree 1: 1 2 6 24 120 720 5040 40320 362880 3628800
Degree
Degree
Degree
Degree
▲Degree 5 1 2 3 4 5 6 14 24 36 50</pre>
=={{header|Racket}}==
|