We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent a90bda9 commit de39402Copy full SHA for de39402
numpy_questions.py
@@ -46,7 +46,7 @@ def max_index(X):
46
raise ValueError("Input is not a 2D array")
47
i, j = np.unravel_index(np.argmax(X), X.shape)
48
return i, j
49
-
+
50
51
52
def wallis_product(n_terms):
@@ -68,4 +68,13 @@ def wallis_product(n_terms):
68
"""
69
# XXX : The n_terms is an int that corresponds to the number of
70
# terms in the product. For example 10000.
71
- return 0.
72
+ if n_terms < 0:
73
+ raise ValueError("n_terms should be a positive integer")
74
+ if n_terms == 0:
75
+ return 1.
76
77
+ pi = 1.
78
+ for i in range(1, n_terms+1):
79
+ pi *= 4*i**2/(4*i**2-1)
80
+ return 2*pi
0 commit comments