Anonymous user
Combinations and permutations: Difference between revisions
m
→{{header|REXX}}: added/changed comments and whitespace, changed indentations.
m (added whitespace before the TOC (table of contents), added a ;Related task: (bold) header, used a larger font for the formula, italics, sub- and superscripts to make it easier to read.) |
m (→{{header|REXX}}: added/changed comments and whitespace, changed indentations.) |
||
Line 1,281:
=={{header|REXX}}==
The hard part of this REXX program was coding the '''DO''' loops for the various ranges.
<lang rexx>/*REXX program
numeric digits 100 /*use 100 decimal digits of precision. */
do j=1 for 12; _= /*show all permutations from 1 ──► 12.*/
_=_ 'P('j","k')='perm(j,k)" " /*add an extra blank between numbers. */
end /*k*/
say strip(_) /*show the permutations horizontally. */
end /*j*/
say /*display a blank line for readability.*/
do j=10 to 60 by 10; _= /*show some combinations 10 ──► 60. */
_=_ 'C('j","k')='comb(j,k)" " /*add an extra blank between numbers. */
end /*k*/
say strip(_) /*show the combinations horizontally. */
end /*j*/
say /*display a blank line for readability.*/
numeric digits 20 /*force floating point for big numbers.*/
do j=5 to 15000 by 1000; _= /*show a few permutations, big numbers.*/
_=_ 'P('j","k')='perm(j,k)" " /*add an extra blank between numbers. */
end /*k*/
say strip(_) /*show the permutations horizontally. */
end /*j*/
say /*display a blank line for readability.*/
do j=100 to 1000 by 100; _= /*show a few combinations, big numbers.*/
_=_ 'C('j","k')='comb(j,k)" " /*add an extra blank between numbers. */
end /*k*/
say strip(_) /*show the combinations horizontally. */
end /*j*/
exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
perm: procedure;
.combPerm:
!: procedure;
/*──────────────────────────────────────────────────────────────────────────────────────*/
comb:
'''output'''
<pre>
|