The thing is what I typed is what he gave us to use. Supposed to make a function out of it? I thought all along it did not make any sense. Is it possible to start all over and how would I start declaring a function to calculate the Euler's number?
Printable View
The thing is what I typed is what he gave us to use. Supposed to make a function out of it? I thought all along it did not make any sense. Is it possible to start all over and how would I start declaring a function to calculate the Euler's number?
I gave it a go with some random number -- fa (13.0) -> output: 2.71828Code:double fa (double x)
{
double tmp1=0, tmp2=0;
for (int j=1; j<=x; ++j)
{
tmp1 = 1.0;
for (int i=1; i<j; ++i)
{
tmp1 *= i;
}
tmp2 += 1.0 / double(tmp1);
}
return tmp2;
}
Thanks for telling me about removing the return it worked YEAH