SlideShare a Scribd company logo
1 of 1
program fakto;

uses wincrt;

function factorial(n:integer):longint;

begin

if(n=0)then

factorial:=1

else

factorial:=n*factorial(n-1);

end;

function permutasi(a,r:integer):real;

begin

if(a=1)then

permutasi:=1

else

permutasi:=factorial(a)/factorial(a-r);

end;

var x,y:integer;

begin

writeln('program permutasi');

writeln;

write('Berapa banyak n: ');

readln(x);

write('jumlah yang dipilih(r): ');

readln(y);

writeln;

writeln('permutasi =', permutasi(x,y):3:0);

readln;

end.

More Related Content

What's hot

Presentation mcrl2
Presentation mcrl2Presentation mcrl2
Presentation mcrl2
matifch
 
VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits II
Gouthaman V
 

What's hot (20)

MCRL2
MCRL2MCRL2
MCRL2
 
Looping Structures
Looping StructuresLooping Structures
Looping Structures
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
Introducction to Algorithm
Introducction to AlgorithmIntroducction to Algorithm
Introducction to Algorithm
 
Presentation mcrl2
Presentation mcrl2Presentation mcrl2
Presentation mcrl2
 
Mean square error
Mean square errorMean square error
Mean square error
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Tower of HANOI
Tower of HANOITower of HANOI
Tower of HANOI
 
Adding two integers in c
Adding two integers in cAdding two integers in c
Adding two integers in c
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 
C programs
C programsC programs
C programs
 
MFC Rect2
MFC Rect2MFC Rect2
MFC Rect2
 
Loops (1)
Loops (1)Loops (1)
Loops (1)
 
Concept of c
Concept of cConcept of c
Concept of c
 
Asymptoptic notations
Asymptoptic notationsAsymptoptic notations
Asymptoptic notations
 
Removal Of Recursion
Removal Of RecursionRemoval Of Recursion
Removal Of Recursion
 
Insertion sort
Insertion sortInsertion sort
Insertion sort
 
C#
C#C#
C#
 
VLSI Sequential Circuits II
VLSI Sequential Circuits IIVLSI Sequential Circuits II
VLSI Sequential Circuits II
 

Permutasi pascal

  • 1. program fakto; uses wincrt; function factorial(n:integer):longint; begin if(n=0)then factorial:=1 else factorial:=n*factorial(n-1); end; function permutasi(a,r:integer):real; begin if(a=1)then permutasi:=1 else permutasi:=factorial(a)/factorial(a-r); end; var x,y:integer; begin writeln('program permutasi'); writeln; write('Berapa banyak n: '); readln(x); write('jumlah yang dipilih(r): '); readln(y); writeln; writeln('permutasi =', permutasi(x,y):3:0); readln; end.