For23. A real number X and an integer N (>0) are given. Find the value of expression
\(X - X^3/(3!) + X^5/(5!) - ... + (-1)^N \cdot X^{2 \cdot N +1}/((2 \cdot N +1)!)\)
(\(N! = 1 \cdot 2 \cdot ... \cdot N\)). The number obtained is an approximate value of the function sin at the point X.

Solution in Python 3:

import math
X = math.pi/4
N = 10
print('X = ', X)
print('N = ', N)

p = X
S = X
k = 0
for i in range(1,N+1):
k += 2
p *= (-1) * X * X / (k * (k + 1))
S += p
print(i," : ", k," : ", k+1," : ", p," : ", S)
print("Result:")
print(S)
print("sin:")
print(math.sin(X))