質問編集履歴
1
コードの追加
test
CHANGED
File without changes
|
test
CHANGED
@@ -19,3 +19,43 @@
|
|
19
19
|
|
20
20
|
|
21
21
|
どうすればよいでしょうか?
|
22
|
+
|
23
|
+
|
24
|
+
|
25
|
+
僕が書いたコードは
|
26
|
+
|
27
|
+
```Python
|
28
|
+
|
29
|
+
def f(x):
|
30
|
+
|
31
|
+
return 1**x
|
32
|
+
|
33
|
+
|
34
|
+
|
35
|
+
def g(x):
|
36
|
+
|
37
|
+
return (-1)**x
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
def sigma(func, frm, to):
|
42
|
+
|
43
|
+
result = 0;
|
44
|
+
|
45
|
+
for i in range(frm, to+1):
|
46
|
+
|
47
|
+
result += func(i)
|
48
|
+
|
49
|
+
return result
|
50
|
+
|
51
|
+
|
52
|
+
|
53
|
+
print(sigma(f,1,30))
|
54
|
+
|
55
|
+
print(sigma(g,1,30))
|
56
|
+
|
57
|
+
```
|
58
|
+
|
59
|
+
|
60
|
+
|
61
|
+
です。
|