+ 2

Please,can anybody help me with this problem

pow(1,1)/1! + pow(2,2)/2! + .... =?

10th Nov 2018, 5:35 PM
Otabek Karimov
Otabek Karimov - avatar
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/
10th Nov 2018, 5:41 PM
Shadow
Shadow - avatar
+ 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
10th Nov 2018, 5:57 PM
Otabek Karimov
Otabek Karimov - avatar
+ 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.
10th Nov 2018, 6:17 PM
Shadow
Shadow - avatar
+ 2
Oh thanks.It works I didn't know this way.
10th Nov 2018, 6:41 PM
Otabek Karimov
Otabek Karimov - avatar
19th Mar 2019, 10:16 AM
Nayana R K
Nayana R K - avatar