in Combinatory
725 views
0 votes
0 votes

Please see example 6. l am not getting the mathematical insight. Can anyone please tell how they are arriving at the answer.

in Combinatory
by
725 views

1 Answer

0 votes
0 votes
Suppose you want to dress and you have 3 pants 2 shirts. So for first shirt there are 3 pants and for another one another 3. So total there are 6 different styles in which you can dress.

Now similarly, let us take only 3 for loop of i, j and m. For the first for loop i let it iterate from 1 to 3, for j 1 to 3 and m 1 to 2.

For first i = 1 , j can take 3 values and for each 3 values of j, m will take 2 iteration.

So k will increment twice k=2 after first iteration of j.

At last iteration of j of i=1.

K will be twice * no of iterations of j

So k= 6

Now i =2

Again k which increment its value from 6 to 12.

At last i=3, k will be again 12+6.

So at the end k will be 18.

i.e. k = 3*3*2.

Which is same as k = n1*n2*n3.

n1- range of i.

n2- range of j.

n3- range of k.

This is same as the number of ways for dressing if you have n1 pants, n2 shirts and n3 shoes.

Apply the product rule.

Related questions

Quick search syntax
tags tag:apple
author user:martin
title title:apple
content content:apple
exclude -tag:apple
force match +apple
views views:100
score score:10
answers answers:2
is accepted isaccepted:true
is closed isclosed:true