This script does Factorials or Permutations or Combinations or all of them for you. Just set up the const then hit run.



PHP Code:
var
  
DoFactorialDoCombinationDoPermutationBoolean;

const
{
Permutation Setup}
  
Book  4//How many objects there are.
  
Shelf 2// How many slots there are.
  
  
{Combination Setup}
  
Candy 4//How many objects there are.
  
Jars  2// How many slots there are.

{Factorial Setup}
  
Num   4// Number to factorize.

procedure Setup;
begin
  
case Lowercase(Readln('Do Factorials? Yes/No')[1]) of
                  
'y'DoFactorial:=  True;
                  
'n'DoFactorial:=  False;
  
end;
                
                
  case 
Lowercase(Readln('Do Combinations? Yes/No')[1]) of
                    
'y'DoCombination:= True;
                    
'n'DoCombination:= False;
  
end;
                  
                  
  case 
Lowercase(Readln('Do Permutations? Yes/No')[1]) of
                    
'y'DoPermutation:= True;
                    
'n'DoPermutation:= False;
  
end;
end;
  
  
  
function 
Factorial(z:Integer):Integer;
var
  
xa:Integer;
begin
  a
:=z;
  for 
x:= 1 to z-do
    
begin
      a
:= a* (z-x);
    
end;
    
Result:= A;
end;

function 
Permutation(ze:Integer):Integer;
var
  
RP:Integer;
begin
  R
:= Factorial(z);
  
P:= z-e;
  
Result:= R div Factorial(P);
end;

function 
Combination(HL:Integer):Integer;
var
  
SOQ:Integer;
begin
  S
:= Factorial(H);
  
Q:= H-L;
  
O:= Factorial(L)*Factorial(Q);
  
Result:=S div O;
end;

procedure RP;
begin
  
if (DoFactorialthen
    begin
      Writeln
('The factorial of '+IntToStr(Num)+' is '+IntToStr(Factorial(Num)));
      
Writeln(' ');
    
end;
  if (
DoCombinationthen
    begin
      Writeln
('The number of Combinations for '+InttoStr(Candy)+' thing[s] taken '+Inttostr(Jars)+',');
      
Writeln('at a time is '+IntToStr(Combination(CandyJars)));
      
Writeln(' ');
    
end;
  if (
DoPermutationthen
    begin
      Writeln
('The number of Permutations for '+InttoStr(Book)+' thing[s] taken '+Inttostr(Shelf)+',');
      
Writeln('at a time is '+IntToStr(Permutation(BookShelf)));
      
Writeln(' ');
    
end;

end;


begin
  SetUp
;
  
RP
end