Salut,
Un bout de code piqué qque part...
Public Function F(ByVal n As Integer) As Long 'Factorial of n (n = 0 to not greater th ' an 12, that gives 479,001,600) 'THIS ROUTINE IS RECURSIVE, i.e. calls i ' tself Static RecursivePass As Boolean 'input control
If Not RecursivePass Then 'first pass Dim OK As Boolean
Select Case n Case 0 To 12 OK = True End Select If Not OK Then F = -1: Exit Function RecursivePass = True End If 'calculation F = 1
If n - 1 >= 0 Then F = n * F(n - 1) Else RecursivePass = False End If End Function
Tchao
NéoB
------------------------------- Réponse au message : -------------------------------
salut, je cherche à programme la fonction factorielle en récursif ... comment faire pour la condition d'arrêt en vb fouesoft
|