2016年11月3日 星期四

10/28 隨堂練習訂正

10/28 隨堂練習訂正

  •  'p27 輸入正整數 n,求(1-1/2)(1-1/3)(1-1/4)...(1-1/n) =
  •     Private Sub Button11_Click(sender As Object, e As EventArgs) Handles Button11.Click
            'p27 輸入正整數 n,求(1-1/2)(1-1/3)(1-1/4)...(1-1/n) =
            Dim ans As Single
            Dim n As Integer
            n = InputBox("n=", "p27 輸入正整數 n,求(1-1/2)(1-1/3)(1-1/4)...(1-1/n) =", 4)
            ans = 1
            For i = 2 To n
                ans *= 1 - 1 / i
            Next
            Me.TextBox17.Text = ans
        End Sub 


    沒有留言:

    張貼留言