contagem.mws

Permutações e Combinações

9/10/2007

 > with(combinat);

```Warning, the protected name Chi has been redefined and unprotected

```

Expansão do Binómio

 > for n from 1 to 7 do

 > sort(expand((x+y)^n));

 > od;

Triângulo de Pascal

 > for n from 1 to 9 do

 > seq(binomial(n,k),k=0..n);

 > od;

Combinações

 > randcomb(3,2);

 > numbcomb(3,2);

 > numbcomb(3,3);

 > with(combstruct);

 > allstructs(Combination([a,b,c]), size=2);

 > choose([a,b,c], 2);

 > allstructs(Combination([a,b,c]), size=3);

 > choose([a,b,c], 3);

 > allstructs(Combination([1,2,3,4,5]), size=3);

 > allstructs(Combination([1,2,3,4,5,6,7]), size=3);

 > choose([1,2,3,4,5], 3);

Permutações

 > allstructs(Permutation([1,2,3,4]));

 > permute([a, b, c],2);

 > numbperm(3, 2); numbperm(3, 3);

 > numbcomb(40,6);

Exemplo 2 (Lotaria)

 > for n from 30 to 50 do

 > n, numbcomb(n,6), evalf(1/numbcomb(n,6));

 > od;

 > with(plots);

 > lotaria := proc(a,b::integer)

 > local w,n,i;

 > for n from a to b do

 > w[n]:=1/numbcomb(n,6);

 > od;

 > pointplot({seq([i,w[i]],i=a..b)},symbol=circle,symbolsize=12,color=red,axes=boxed):

 > end:

 > lotaria(30,50);

 >