Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to do Factorials in VFP with Recursion
Message
 
 
To
21/02/2000 23:54:51
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00335196
Message ID:
00335236
Views:
20
Doug,

You may use recursion, if you're calculating a determinant. I created a recursion-based program in VB...

BTW, it's a well-known fact, that each recursive program could be done in non-recursive way too.

>>May I say that factorials are the best example for where to not use recursion?
>
>Absolutely!! I think these kinds of threads bring light to all.
>
>>Here's a much simplier, faster
>>and cmore compact version: <g>
>
>Show off! *bg* (he says as he harrumphs and sulks into his corner *g*)
>
>>
>
func Factorial
>lparam tnNumber
>   local lnResult
>   lnResult = 1
>
>   for lnI = 2 to tnNumber
>      lnResult = lnResult * lnI
>   endfor
>
>return lnResult
>
>Best regards,
>
>DD
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform