#include
using namespace std;
int factorial(int n){
if(n==0 || n==1)
return 1;
else
return n*factorial(n-1);
}
int main(){
int n;
cin>>n;
cout<<factorial(n)<<endl;
return 0;
}
#include
using namespace std;
int factorial(int n){
if(n==0 || n==1)
return 1;
else
return n*factorial(n-1);
}
int main(){
int n;
cin>>n;
cout<<factorial(n)<<endl;
return 0;
}
u cannot calculate factorial of large numbers such as 100! using this as 100! exceeds 10^18.
So in order to calculate such large factorials, u need to use multiplication using arrays.
like first array={0,0,0,0,0,0,1}
then multiply by 2,3 to make array={0,0,0,0,0,0,6}
then multiply by 4 to make array = {0,0,0,0,0,1,2}
and so on calculate large factorial.
Hope dis resolve ur doubt.
If u still hv any doubts, feel free to post them here
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.