Hey, I am doing this program which does factorial for bigger numberslike 300, I
ID: 3612361 • Letter: H
Question
Hey,I am doing this program which does factorial for bigger numberslike 300, I have problems with arrays once again. I can do thisrecursively but not in array. HELP PLS!! I am posting my work belowwith recursion
#include <iostream>
#include <iomanip>
using namespace std;
long double factorial(long double factorialParameter){
if(factorialParameter<=1){
return 1;
}
else{
//factorial=factorial*(factorial -1)
returnfactorialParameter*factorial(factorialParameter-1);
}
}
int main() {
int n;
long double answer;
cout << "Enter a number for factorial computation and pressENTER: ";
cin >> n;
answer=factorial(n);
cout<<fixed;
cout<<n<<"!"<<" (by Factorial Function) is"<<answer<<" ";
system("pause");
return 0;
}
Will definitely rate you!! thx
Explanation / Answer
please rate - thanks #include #include using namespace std; long double factorial(int factorialParameter){ long double fact[500]; int i; fact[0]=1; fact[1]=1; for(i=2;i n; answer=factorial(n); coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.