Advertisement
MadCortez

Untitled

Apr 13th, 2022
1,743
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Sub Main()
  2.     Dim x As Double
  3.     Dim a As Single
  4.     x = InputBox("Ââåäèòå çíà÷åíèå ïåðåìåííîé")
  5.     a = InputBox("Ââåäèòå òî÷íîñòü")
  6.     MsgBox ("" & Teylor(x, a))
  7. End Sub
  8.  
  9. Function Teylor(x, a)
  10.     Dim Sum As Integer, n As Integer
  11.     Dim FactN As Long, Fact As Long
  12.     Dim Prev As Double, Now As Double
  13.     Dim Ans As Double
  14.     Prev = 0
  15.     Sum = 0
  16.     n = 0
  17.     Do While 1 = 1
  18.         Fact = 1
  19.         For i = 1 To 2 * n Step 1
  20.             Fact = Fact * i
  21.             Next i
  22.         FactN = 1
  23.         For i = 1 To n Step 1
  24.             FactN = FactN * i
  25.             Next i
  26.         Now = ((-1) ^ n * Fact) / ((4) ^ n * ((FactN) ^ 2) * (2 * n + 1)) * (x) ^ (2 * n + 1)
  27.         If Abs(Prev - Now) <= a Then
  28.             Exit Do
  29.         End If
  30.         Prev = Now
  31.         Ans = Ans + Now
  32.         n = n + 1
  33.     Loop
  34.     Teylor = Ans
  35. End Function
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement