Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <conio.h>
- using namespace std;
- int fact(int x)
- {
- if (x <= 0)
- return 1;
- else return x * fact(x -1);
- }
- int main()
- {
- int n;
- cout <<"enter value = ";
- cin>>n;
- cout << "factorial = ";
- cout << fact(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement