title: maclaurin series for sin(x)
body: <p>I wrote a program to calculate sin(x) using the Maclaurin series but when I tried debugging it, it is giving an overflow error. Here is the code, can anyone help me out?</p>
  
  <pre><code>Public Class Form1
      Private Function sin(ByVal x As Double) As Double
          Dim sinx, radx, abc As Double
          sinx = 0
          radx = x * Math.PI / 180
          For i = 1 To 20 Step 2
              abc = (Math.Pow(-1, (i / 2)) * Math.Pow(radx, i)) / factorial(i)
              sinx += abc
          Next
          Return sinx
      End Function
  
      Private Function factorial(ByVal n As Integer) As Integer
          If (n = 0) Or (n = 1) Then
              Return 1
          Else
              Return n * factorial(n - 1)
          End If
      End Function
  
      Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
  
      End Sub
  
      Private Sub BtnCalc_Click(sender As Object, e As EventArgs) Handles BtnCalc.Click
          Dim x As Integer
          x = Val(TxtInput.Text)
          TxtAns.Text = sin(x)
      End Sub
  End Class
  </code></pre>