Remove .md and image files and move python files into main chapter folders
This commit is contained in:
parent
5978779a9a
commit
67806dab6a
159 changed files with 0 additions and 4562 deletions
20
thinkcspy/Chapter-6-Exercises/problem16.py
Normal file
20
thinkcspy/Chapter-6-Exercises/problem16.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 6
|
||||
# Problem 16
|
||||
|
||||
import math
|
||||
|
||||
def myPi(iters):
|
||||
# Calculate an approximation of PI using the Madhava
|
||||
# approximation with iters number of iterations
|
||||
|
||||
#your code here
|
||||
apprPi = 0
|
||||
|
||||
for i in range(iters):
|
||||
term = (-1)**i/((2*i+1)*3**i)
|
||||
apprPi += term
|
||||
|
||||
return apprPi * math.sqrt(12)
|
||||
|
||||
print(myPi(10))
|
||||
Loading…
Reference in a new issue