Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Sub Main()
- Dim x As Double
- Dim a As Single
- x = InputBox("Ââåäèòå çíà÷åíèå ïåðåìåííîé")
- a = InputBox("Ââåäèòå òî÷íîñòü")
- MsgBox ("" & Teylor(x, a))
- End Sub
- Function Teylor(x, a)
- Dim Sum As Integer, n As Integer
- Dim FactN As Long, Fact As Long
- Dim Prev As Double, Now As Double
- Dim Ans As Double
- Prev = 0
- Sum = 0
- n = 0
- Do While 1 = 1
- Fact = 1
- For i = 1 To 2 * n Step 1
- Fact = Fact * i
- Next i
- FactN = 1
- For i = 1 To n Step 1
- FactN = FactN * i
- Next i
- Now = ((-1) ^ n * Fact) / ((4) ^ n * ((FactN) ^ 2) * (2 * n + 1)) * (x) ^ (2 * n + 1)
- If Abs(Prev - Now) <= a Then
- Exit Do
- End If
- Prev = Now
- Ans = Ans + Now
- n = n + 1
- Loop
- Teylor = Ans
- End Function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement