Java to VB

cs_jmtoulon Messages postés 85 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 3 août 2010 - 20 févr. 2006 à 12:15
cs_jmtoulon Messages postés 85 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 3 août 2010 - 20 févr. 2006 à 13:36
<OL>
<LI>Bonjour, je souhaiterais la traduction de ce code java en Vb plzzz :)
Merci par avance c'est pour ma fonction math :)

private
static
int
legendre(
BigInteger
n,
int
p) { </LI>
<LI>
int
a = n.remainder(
BigInteger
.valueOf(p)).intValue() ;
<LI>
int
m = p ;
<LI>
int
t = 1 ;
<LI>
<LI>
while
(a != 0) {
<LI>
int
k = m % 8 ;
<LI>
boolean
zyva k 3 || k == 5 ;
<LI>
<LI>
while
(a % 2 == 0) {
<LI> a /= 2 ;
<LI>
if
(zyva)
<LI> t = -t ;
<LI> }
<LI>
int
swap a ; a m ; m = swap ;
<LI>
int
x a % 4, y m % 4 ;
<LI>
if
(x 3 && x y)
<LI> t = -t ;
<LI> a = a % m ;
<LI> }
<LI>
if
(m == 1)
<LI>
return
t ;
<LI>
else

<LI>
return
0 ;
<LI> } </LI></OL>

2 réponses

cs_DARKSIDIOUS Messages postés 15814 Date d'inscription jeudi 8 août 2002 Statut Membre Dernière intervention 4 mars 2013 130
20 févr. 2006 à 12:59
Hum, elle est pourtant très ressemblante à du vb !

Ca doit donner un truc dans ce genre :

<ol><li>private
function
 legendre(byval n as long, 
byval
p as integer) As Integer
</li><li>Dim a as integer</li><li>dim m as integer</li><li>dim t as integer</li><li>dim k as integer</li><li>dim zyva as boolean</li><li>dim swap as integer</li><li>dim x as integer
</li><li></li><li>a n
</li><li>m
p </li><li>t = 1 </li><li> </li><li>
while
(a <> 0) </li><li>
k m mod 8  </li><li>     zyva iif(k = 3 or k = 5, true, false)  </li><li> </li><li>      
while
(a mod 2 0) </li><li> a a / 2 ; </li><li>
if
(zyva) then t = -t </li><li> wend </li><li> swap = a</li><li> a = m</li><li> m swap </li><li> x a mod 4</li><li> y = m mod 4 </li><li>
if
(x = 3 and x = y) then t = -t ; </li><li> a = a mod m </li><li> Wend </li><li>
if
(m = 1) then </li><li> legendre = t </li><li>
else
</li><li> legendre = 0 </li><li> end if</li><li>end function
</li></ol>
_
0
cs_jmtoulon Messages postés 85 Date d'inscription dimanche 1 avril 2001 Statut Membre Dernière intervention 3 août 2010
20 févr. 2006 à 13:36
Merci pour ton aide, cela marche parfaitement :) Merci encore :) merciiiiii :)
0
Rejoignez-nous