#include<iostream>
#include<conio.h>
using namespace std;
int faktorial (int x);
int main()
{
int n,r, Permutasi;
cout<<" Program Menghitung Permutasi(nPr)";
cout<<endl;
cout<<" Masukkan Nilai n : "; cin>>n;
cout<<" Masukkan Nilai r : "; cin>>r;
Permutasi = faktorial (n)/faktorial(n-r);
cout<<" Permutasinya adalah: "<<Permutasi;
getch();
}
int faktorial (int n)
{
int fak;
if (n<=1)
{
fak=1;
}
else
{
fak=n*faktorial(n-1);
}
return (fak);
system("PAUSE");
EXIT_SUCCESS;
}
No comments:
Post a Comment