Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
How to do Factorials in VFP with Recursion
Message
De
22/02/2000 00:06:50
 
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00335196
Message ID:
00335238
Vues:
16
Hi Nadya!,

Let me ask you this as, perhaps, a means of expanding on this discussion a little....

What 'types' of programs do you recommend using recursion? I've used them for multi-level types of organizations and relationships where they seem to do well. I'm curious as to other types of applications as well.

Best,

DD

>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
Best,


DD

A man is no fool who gives up that which he cannot keep for that which he cannot lose.
Everything I don't understand must be easy!
The difficulty of any task is measured by the capacity of the agent performing the work.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform