Hi, maybe somebody understands the amount of the series,how to do it right and how it works? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Hi, maybe somebody understands the amount of the series,how to do it right and how it works?

infinity ; k=1; 1/kx^k for all integer values ​​of the segment X[0,5] https://code.sololearn.com/cX6V6uHE11rr/?ref=app

1st Jun 2021, 10:14 AM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
5 Answers
0
When you use C libraries in C++, include them with 'c' prefix like: #include <cmath> Btw you included iostream, but use cstdio (you are using printf instead of cout for some reason) What do you mean by "amount" of series? Sum? You can't actually make it to infinity, because it will work forever. You can set a limit and check if the n-th element is less than the limit, then break out of the loop. I would use do-while loop to calculate sum of the infinite series with the rule I mentioned
1st Jun 2021, 10:25 AM
Michal Doruch
0
Your line number 10 you decleared x variable after this line double f1 = -log(x - 1 / x) Here your x is undefined and undeclared for this expression. your variables are not decleared in particular scope
1st Jun 2021, 10:35 AM
A S Raghuvanshi
A S Raghuvanshi - avatar
0
i use printf and math.h cause nothing change in comparing with C++ lib, yes i wanna get sum , but i am not fully aware how to do it ,probably [0,5] is a limit
1st Jun 2021, 10:35 AM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
0
A.S i know that, i just briefly wrote a code
1st Jun 2021, 10:37 AM
Aleks kryzhanivskyi
Aleks kryzhanivskyi - avatar
0
You can use printf, but use correct header files, as you are writing your code as C++. These languages are not the same.
1st Jun 2021, 10:47 AM
Michal Doruch