Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do Factorials in VFP with Recursion
Message
 
 
À
21/02/2000 23:54:51
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00335196
Message ID:
00335236
Vues:
21
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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform