+ 2
Please,can anybody help me with this problem
pow(1,1)/1! + pow(2,2)/2! + .... =?
5 Respostas
+ 4
It would be best for us if you shared some attempt of yours that we can help you with, otherwise your question is a bit unspecific. What exactly is it that you need help with?
You can get a power function through the <cmath> library:
http://www.cplusplus.com/reference/cmath/pow/
And an example for a simple recursive factorial function is covered by the Sololearn C++ course:
https://www.sololearn.com/learn/CPlusPlus/1641/
+ 3
The problem is that I don't know mathematical formula for this equation
I know how to use pow and recursive function but I can't combine them in this problem
+ 3
You have the formula written above. If you translate that to C++ code, you should have a variable that holds for how many numbers your formula runs, and then you can use a for-loop to iterate from 1 to n. In each iteration, you use your formula and add the result to some other variable.
So, for example:
double result {0.0};
for (unsigned i = 1; i < n; ++i) {
result += pow(i, i) / factorial(i);
}
And in the end, you can output the result.
+ 2
Oh thanks.It works
I didn't know this way.