Загрузка данных


Sub CalculateAll()
    Dim x As Double, s1 As Double, s2 As Double, t1 As Double, t2 As Double
    Dim i As Integer, n1 As Integer, n2 As Integer
    Dim fact5 As Double, fact8 As Double, j As Integer
    
    x = 0.5
    s1 = 0
    t1 = 1
    i = 0
    Do
        s1 = s1 + t1
        If t1 <= 0.0001 Then Exit Do
        t1 = t1 * x
        i = i + 1
    Loop
    n1 = i + 1
    
    s2 = 0
    t2 = 1
    i = 0
    Do
        s2 = s2 + t2
        If Abs(t2) <= 0.0001 Then Exit Do
        t2 = -t2 * x
        i = i + 1
    Loop
    n2 = i + 1
    
    fact5 = 1
    For j = 1 To 5
        fact5 = fact5 * j
    Next j
    
    fact8 = 1
    For j = 1 To 8
        fact8 = fact8 * j
    Next j
    
    Range("A1:C10").ClearContents
    
    Range("A1").Value = "Вычисление"
    Range("B1").Value = "Результат"
    Range("C1").Value = "Примечание"
    
    Range("A2").Value = "Геометрический ряд (1+x+x^2+...), x=0,5"
    Range("B2").Value = Round(s1, 4)
    Range("C2").Value = "Слагаемых: " & n1
    
    Range("A3").Value = "Знакочередующийся ряд (1-x+x^2-x^3+...), x=0,5"
    Range("B3").Value = Round(s2, 4)
    Range("C3").Value = "Слагаемых: " & n2
    
    Range("A5").Value = "5!"
    Range("B5").Value = fact5
    Range("C5").Value = "= 1×2×3×4×5"
    
    Range("A6").Value = "8!"
    Range("B6").Value = fact8
    Range("C6").Value = "= 1×2×3×4×5×6×7×8"
End Sub