回答編集履歴
1
追記
test
CHANGED
@@ -25,3 +25,39 @@
|
|
25
25
|
sum += ((-1)**k)*(x**(2*k))/fact
|
26
26
|
|
27
27
|
```
|
28
|
+
|
29
|
+
|
30
|
+
|
31
|
+
累算代入演算子だけの場合です。
|
32
|
+
|
33
|
+
```python3
|
34
|
+
|
35
|
+
n = int(input('正の整数nの値を入力してください: '))
|
36
|
+
|
37
|
+
x = float(input('実数xの値を入力してください: '))
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
sum = 0
|
42
|
+
|
43
|
+
|
44
|
+
|
45
|
+
for k in range(1,n+1):
|
46
|
+
|
47
|
+
ak = 1
|
48
|
+
|
49
|
+
for j in range(k):
|
50
|
+
|
51
|
+
ak *= -1
|
52
|
+
|
53
|
+
for i in range(2*k):
|
54
|
+
|
55
|
+
ak *= x
|
56
|
+
|
57
|
+
for h in range(1,2*k+1):
|
58
|
+
|
59
|
+
ak /= h
|
60
|
+
|
61
|
+
sum += ak
|
62
|
+
|
63
|
+
```
|