Example 25: Natural Logarithm Series
Learn how to print a logarithmic series.
We'll cover the following
Problem
The natural logarithm can be approximated by the following series.
If x is an input to a function, write a program to calculate the sum of this series’s first seven terms.
Example
Input | Output |
---|---|
3 | 1.086367 |
2 | 0.692262 |
0 | -1 |
-10 | -1 |
Try it yourself
Try to solve this question on your own in the code widget below. If you get stuck, you can always refer to the solution provided.
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.