For 27. Дано вещественное число X (|X| < 1) и целое число N (> 0). Найти значение выражения
\(X + 1 \cdot X^3/(2 \cdot 3) + 1 \cdot 3 \cdot X^5/(2 \cdot 4 \cdot 5) + ... + \\
+ 1 \cdot 3 \cdot ... \cdot (2 \cdot N - 1) \cdot X^{2 \cdot N +1}/(2 \cdot 4 \cdot ... \cdot (2 \cdot N ) \cdot (2 \cdot N +1)).\)
Полученное число является приближенным значением функции arcsin в точке X.

Решение на Python 3

import math
X = 0.9
N = 100
print('X = ', X)
print('N = ', N)

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

print("Result:")
print(S)
print("asin(x):")
print(math.asin(X))

Решение на C++

#include <bits/stdc++.h>
using namespace std;

int main() {
srand((int)time(0));
int N;
N = rand() % 30 + 1;
//N = 30;
double X = (rand() % 200 - 100) / 100.0;
//X = 0.1;

double p = X, s = X;
double k = 1.0;
for(int i = 1; i <= N; i++) {
p *= k/((k+1)*(k+2))*X*X;
s += p;
cout << i << " : "<< p << " : "<< s << endl;
k += 2;
p *= k;
}
cout << "Number N: " << N << endl;
cout << "Number X: " << X << endl;
cout << "Result: " << s << endl;
cout << "asin(" << X <<") = " << asin(X) << endl;

return 0;
}