Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Coded and executed on CodeBlock
- // C++ Code for factorial using recursive function
- #include <iostream>
- using namespace std;
- int fact(int x)
- {
- double f=1;;
- if(x==1)
- {
- return 1;
- }
- else{
- f=x*fact(x-1);
- return f;
- }
- }
- int main()
- {
- int n;
- cout << "\t\tFactorial Finder \n";
- cout << "Enter Number : ";
- cin >>n;
- cout << fact(n);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement