Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions factorial.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include<iostream>
using namespace std;

// function to find factorial of given number
unsigned int factorial(unsigned int n)
{
if (n == 0)
return 1;
return n * factorial(n - 1);
}

// Driver code
int main()
{
int num;
cout<<"enter the number :";
cin>>num;
cout << "Factorial of " << num << " is " << factorial(num) << endl;
return 0;
}
Binary file added factorial.exe
Binary file not shown.
Binary file added factorial.o
Binary file not shown.