Welcome to Gaia! :: View User's Journal | Gaia Journals

 
 

View User's Journal

Subscribe to this Journal
Diary of a programmer.
A daily journal of the life of a high school student, interested in programming.
School spawns ideas!
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
Community Member
Lustrous Soul
Prev | Next
Archive | Home

  • [12/05/09 07:21pm]



  •  
     
    Manage Your Items
    Other Stuff
    Get GCash
    Offers
    Get Items
    More Items
    Where Everyone Hangs Out
    Other Community Areas
    Virtual Spaces
    Fun Stuff
    Gaia's Games
    Mini-Games
    Play with GCash
    Play with Platinum