Chat LIVE With Programming Experts! There Are 23 Online Right Now...

 

Code Snippets

  

VB.NET Source Code


Welcome to Dream.In.Code
Become a VB.NET Expert!

Join 244,212 VB.NET Programmers for FREE! Get instant access to thousands of VB.NET experts, tutorials, code snippets, and more! There are 1,491 people online right now. Registration is fast and FREE... Join Now!





Recursive Factorial Function

Gets the factorial of a given double using a recursive function

Submitted By: nofear217
Actions:
Rating:
Views: 1,354

Language: VB.NET

Last Modified: July 22, 2008

Snippet


  1. ''' <summary>
  2. ''' Get the factorial of a given number
  3. ''' </summary>
  4. ''' <param name="number">The number that you want the factorial of</param>
  5. ''' <returns>The factorial of a given number</returns>
  6. ''' <remarks></remarks>
  7. Private Function Factorial(ByVal number As Double) As Double
  8.  
  9.         If number <= 1 Then
  10.                 Return (1)
  11.         Else
  12.                 Return number * Factorial(number - 1)
  13.         End If
  14.  
  15. End Function

Copy & Paste


Comments


53greek53 2008-12-03 22:39:16

Is there any way to put the number in one text box on one side of a form and its factorial in another column. just numbers 1-20

nofear217 2008-12-04 08:35:06

Not exactly sure what you're asking, are you wanting the cumulative total as it moves through? Or just the numbers it's recursing?


Add comment


You must be registered and logged on to </dream.in.code> to leave comments.





Live VB.NET Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

VB.NET Tutorials

Reference Sheets

VB.NET Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month