cs_jmtoulon
Messages postés85Date d'inscriptiondimanche 1 avril 2001StatutMembreDernière intervention 3 août 2010
-
20 févr. 2006 à 07:18
cs_jmtoulon
Messages postés85Date d'inscriptiondimanche 1 avril 2001StatutMembreDernière intervention 3 août 2010
-
20 févr. 2006 à 12:14
Bonjour, je cherche à créer une fonction Math en VB
J'ai trouvé l'equivalent en c++ seulement il faudrais que quelqu'un de tres gentil me le traduise en VB svp ::)
Egyde
Messages postés158Date d'inscriptionlundi 17 mai 2004StatutMembreDernière intervention16 juillet 2007 20 févr. 2006 à 09:52
C'est pas tout à fait ça econs (int en C++ devient Long en VB. De plus, quand on return, on quitte la fonction, ie ton programme relance Jacobi si "m And 1" et "m=0"
Public Function jacobi(ByVal m As Long, ByVal n As Long)
Dim t As Long
If (m > n) Then
m = m Mod n
End If
If (m 0) Then jacobi 0: Exit Function
If (m 1) Then jacobi 1: Exit Function
If (m = 2) Then
If (n And 1)=0 Then jacobi = 0: Exit Function
t n And 7; ' t n % 8
If (t 1) Or (t 7) Then
jacobi = 1
Else
jacobi = -1
End If
Exit Function
End If
If ((m And 1) = 0) Then
jacobi = jacobi(m\2,n)*jacobi(2,n)
ElseIf (m And 3)=3 And (n And 3)=3 Then
jacobi = -jacobi(n,m)
Else
jacobi = jacobi(n,m)
End If