/*PROGRAM FAKTORIAL*/
#pragma argsused
#include<conio.h>
#include<iostream.h>
#include<math.h>
int main()
{
int n, a, b, i, fak, j;
cout<<"PROGRAM FAKTORIAL"<<endl;
cout<<"================="<<endl;
cout<<"Masukkan Nilai FALTORIAL : "; cin>>n;
fak=n-1;
for(i=1;i<=fak;i++)
{
a=1;
cout<<i<<"! = ";
for(j=1;j<=i;j++) a=a*j;
cout<<a;
cout<<endl;
}
cout<<"-----------------------------------"<<endl;
cout<<n<<"! = ";
for(i=1;i<=fak;i++) cout<<i<<"*";
cout<<n;
cout<<endl;
b=1;
cout<<n<<"! = ";
for(i=1;i<=n;i++) b=b*i;
cout<<b;
getch();
}
0 komentar:
Posting Komentar