MMs = [ 3 4 5 6];

Ks = [1:6];

RR=cols(MMs);
RC=cols(Ks);

P=R=zeros(RR,RC);

MISSED=1;

for( i = 1; i <= RR; ++i) {
  MM = MMs(i);
  for( j = 1; j <= RC; ++j) {
    K = Ks(j);
    if( K <= MM) {
      setup_combos();
      R(i,j) = rows(combos);
      P(i,j) = sum(unique_perms(:)!=0);
    }
  }
}

;;

/* results:

     R     K = 1       2       3       4       5       6

  MM = 3       4       7       8
       4       5      11      15      16
       5       6      16      26      31      32
       6       7      22      42      57      63      64


     P     K = 1       2       3       4       5       6

  MM = 3       4      13      34
       4       5      21      73     209
       5       6      31     136     501    1546
       6       7      43     229    1045    4051   13327
*/
