feat: pi calculator and chunk array

This commit is contained in:
newt 2024-10-09 18:02:45 +01:00
parent 529993aa5c
commit 0612c6ac59
2 changed files with 13 additions and 1 deletions

View 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)

View file

@ -8,4 +8,4 @@ def chunkArray(array, chunkCount):
return chunks return chunks
print(chunkArray([1,2,3,4,5,6], 3)) print(chunkArray([1,2,3,4,5,6], 4))