RosettaCodeData/Task/Combinations-and-permutations/Quackery/combinations-and-permutations.quackery
2025-02-27 18:35:13 -05:00

21 lines
516 B
Text

[ 1 swap times [ i^ 1+ * ] ] is ! ( n --> n )
[ dip dup - ! dip ! / ] is p ( n n --> n )
[ tuck p swap ! / ] is c ( n n --> n )
' [ [ 1 0 ] [ 12 4 ] [ 60 20 ] [ 105 103 ] [ 15000 333 ] ]
witheach
[ unpack 2dup
say " P("
swap echo say "," echo
say ") = "
p shorten echo$ cr ]
cr
' [ [ 10 5 ] [ 60 30 ] [ 50 48 ] [ 900 675 ] [ 970 730 ] ]
witheach
[ unpack 2dup
say " C("
swap echo say "," echo
say ") = "
c shorten echo$ cr ]