feat: pi calculator and chunk array
This commit is contained in:
parent
529993aa5c
commit
0612c6ac59
2 changed files with 13 additions and 1 deletions
12
languages/python/calculators/pi.py
Normal file
12
languages/python/calculators/pi.py
Normal file
|
@ -0,0 +1,12 @@
|
|||
import math
|
||||
|
||||
pi = 0
|
||||
|
||||
for k in range(20):
|
||||
numerator = (2 ** k) * (math.factorial(k) ** 2)
|
||||
denominator = math.factorial((2 * k) + 1)
|
||||
|
||||
pi += numerator / denominator
|
||||
|
||||
pi *= 2
|
||||
print(pi)
|
|
@ -8,4 +8,4 @@ def chunkArray(array, chunkCount):
|
|||
|
||||
return chunks
|
||||
|
||||
print(chunkArray([1,2,3,4,5,6], 3))
|
||||
print(chunkArray([1,2,3,4,5,6], 4))
|
||||
|
|
Loading…
Reference in a new issue