J
jtnpham
Okay so I have a label with the ID = lblResult. I want to display
each factorial of 1 through five. But when I run my program it only
displays the value of 5!. Can someone help me put the values of 1! -
4!? I would like it to display as follows:
1
2
6
24
120
or
1, 2, 6, 24, 120
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim n, sum As Integer
getFactorial(n, sum)
End Sub
Private Function getFactorial(ByVal n As Integer, ByRef sum As
Integer) As Integer
Dim i As Integer
n = 0
sum = 1
For i = 1 To 5
n = n + 1
sum = n * sum
lblResult.Text = sum
Next i
End Function
Thanks! =)
each factorial of 1 through five. But when I run my program it only
displays the value of 5!. Can someone help me put the values of 1! -
4!? I would like it to display as follows:
1
2
6
24
120
or
1, 2, 6, 24, 120
Here is my code:
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim n, sum As Integer
getFactorial(n, sum)
End Sub
Private Function getFactorial(ByVal n As Integer, ByRef sum As
Integer) As Integer
Dim i As Integer
n = 0
sum = 1
For i = 1 To 5
n = n + 1
sum = n * sum
lblResult.Text = sum
Next i
End Function
Thanks! =)