Vote UpVote

Calculating the factorial of a number in Delphi: Recursive and iterative methods

Yanniel's notes – The factorial function can be defined in both recursive and iterative ways. Take a look at the following definitions borrowed from Wikipedia.Recursive definition: Iterative definition:For both the above definitions we have that: The purpose here is not the mathematical stuff, but two provide the implementation of such definitions in Delphi (Object Pascal). First, I bring you one recursive implementation of the factorial function. Notice how the function calls itself, which is what the recursion really is:function Factorial(aNumber: UInt64): UInt64;begin  Assert(aNumber >= 0, 'The ...
Favorite? Off-Topic? Yanniel @ 2011-07-20 13:59


Visits: 56
Votes: 0
Favorites: 0
Off-Topic: 0

Visits by Source

User Actions

Users who voted for this posting

Contact us to advertise on DelphiFeeds.com

Community Links

Torry Firebird News


Please login or register to use this functionality.
(click on this box to dismiss)