Advertisement
dream_4ild

9-И-3 ex.2

Jan 24th, 2021
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.67 KB | None | 0 0
  1. from math import pi as P
  2.  
  3. # 1 способ
  4. ans=1
  5. for i in range(2,10000000,2):
  6.     ans*=(i/(i-1))
  7.     ans*=(i/(i+1))
  8. ans*=2
  9. print(ans)
  10. print(P-ans)
  11.  
  12. # 2 способ
  13. ans=0
  14. for i in range(1,10000000,4):
  15.     ans+=(1/i)
  16.     ans-=(1/(i+2))
  17. ans*=4
  18. print(ans)
  19. print(P-ans)
  20.  
  21. # 3 способ
  22. ans=0
  23. for i in range(1,10000000):
  24.     ans+=(1/(i**2))
  25. ans*=6
  26. ans**=(1/2)
  27. print(ans)
  28. print(P-ans)
  29.  
  30. # 4 способ
  31. ans=1
  32. for i in range(1,1000):
  33.     ans1=2**(1/2)
  34.     for j in range(i-1):
  35.         ans1+=2
  36.         ans1**=(1/2)
  37.     ans*=(ans1/2)
  38. ans=2/ans
  39. print(ans)
  40. print(P-ans)
  41.  
  42. # Формула Виета является самой быстрой и точной
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement