For25. Given a real number X (| X | < 1) and an integer N (>0). Find the value of expression
\(X - X^2/2 + X^3/3 - ... + (-1)^{N - 1} \cdot X^N/N.\)
The resulting number is an approximate value of the function ln at the point 1 + X.

Solution in Python 3:

import math
X = 0.5
N = 10
print('X = ', X)
print('N = ', N)

p = 1
S = 0
for i in range(1,N+1):
p *= X
S += p/i
print(i," : ", p," : ", S)
p *= -1

print("Result:")
print(S)
print("ln(x+1):")
print(math.log(X+1))