Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- using namespace std;
- int faktorial(int n){
- if(n <= 1){
- cout<< n;
- return n;
- }
- else{
- cout<<""<< n << " x ";
- return n * faktorial(n - 1);
- }
- }
- int main(){
- int angka, hasil;
- cout<<"\t Mencari Nilai Faktorial Dari Suatu Bilangan \n\n";
- cout<<"\n Masukkan Bilangan : ";cin>>angka;
- cout<<endl;
- hasil = faktorial(angka);
- cout<<endl;
- cout<<"\n Nilai Faktorialnya : "<< hasil <<endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement