StoryMakerTV

[PYTHON 3] PI-Näherungswert nach John Wallis (v2)

May 24th, 2011
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.38 KB | None | 0 0
  1. #John Wallis
  2. #PI
  3. #http://www.maths.tcd.ie/pub/HistMath/People/Wallis/RouseBall/wallispi.gif
  4.  
  5. Anzahl = int(input("Anzahl Versuche : "))
  6.  
  7. Nenner = 1
  8. Zaehler = 0
  9. Produkt = 2
  10.  
  11. i = 0
  12.  
  13. while i <= Anzahl:
  14.     if i % 2 == 0:
  15.         Zaehler = Zaehler + 2
  16.     else:
  17.         Nenner = Nenner + 2
  18.        
  19.     i = i + 1
  20.     Produkt = Produkt * (Zaehler / Nenner)
  21.  
  22. print(Produkt)
Advertisement
Add Comment
Please, Sign In to add comment