Today during math class, we 'learned' about factorials.
Ex 5! = 5 * 4 * 3 * 2 * 1 = 120
When I arrived at home, I couldn't help, but spend ten minutes working in Visual Basic to create a form that instantly finds the factorial of any number entered into a text box. Here is what I came up with.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim StartVal As Long StartVal = intxt.Text Dim N As Long N = StartVal - 1 Do While N > 0 StartVal = (StartVal * N) N = N - 1 Loop outtxt.Text = StartVal End Sub
<Sigh>
Lustrous Soul · Sat Dec 05, 2009 @ 07:21pm · 0 Comments |