summaryrefslogtreecommitdiff
path: root/3808/CH6/EX6.6/Ex6_6.sce
blob: 25b0b648e80effc01dee70274cc0ce0ad5b6b520 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
//Chapter 06: Counting

clc;
clear;

function res=permutation(n,r) //function definition
i=n
res=1
l=(n-r)+1
u=n
for i=l:u //computing the permutation
res=res*i
end
return res
endfunction

a=permutation(5,3)//function call
b=permutation(5,5)//function call

mprintf("The number of ways to select 3 students from a group of 5 students to line up for a picture is %d",a) 
mprintf("\nThe number of ways to select 5 students from a group of 5 students to line up for a picture is %d",b)