Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int faktorial(int n);
- main()
- {
- int input;
- cout << "Input n : ";
- cin >> input;
- cout << "Result : ";
- cout << faktorial(input);
- }
- int faktorial(int n)
- {
- int hasil = 1;
- for(int i = n; i > 0; i--)
- {
- hasil = hasil * (i);
- }
- return hasil;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement