I was watching Discovery channel about ancient Indian math, and here's my learned results. Didn't realize how much India came up with until watching that show.
Two functions, for calculating permutations and factorials. (hmm, guess I didn't really need to use the -1 step)
print "A set of 5, with a group of 4 elements"
print "Possbile combinations, ignoring different arrangements: ",permutation(5,4,0)
print "Total of all possible arrangements: ",permutation(5,4,1)
suspend for key
rem Calculates a permutation and returns
rem the number of possible combinations
rem
rem set = number of elements in the set
rem com = number of elements of a group
rem all = boolean, if 0 then all possible
rem arrangements of a group of elements
rem only counts as one group. {1,2,3} = {3,1,2}
rem if all = 1, then the count all possible
rem arrangements of each possible combination
rem is returned
function permutation(set as double integer, com as double integer, all as boolean)
set = factorial(set)
if all=1 then exitfunction set
com = factorial(com)
answer = set / com
endfunction answer
rem Calculates the factorial of X
function factorial(x as double integer)
local y as double integer
y = x
for i=x-1 to 2 step -1
y = y*i
next i
endfunction y