Et UN calcul de PGCD par ici :
print "calcul du plus grand commun diviseur"
input "combien de nombres voulez-vous comparer ";nb
dim n(nb)
maxi=0
for i=1 to nb
print "entrez le nombre numero ";i
input n(i)
next i
cls
print "je recherche le pgcd de ces nombres..."
sort n(, nb, 1
for i=1 to nb
print n(i)
next i
nb1=n(1)
nb2=n(2)
gosub [pgcd]
if nb>2 then
for u=3 to nb
nb1=pgcd
nb2=n(u)
gosub [pgcd]
next u
end if
print "le pgcd est :"
print pgcd
input r$
end
[pgcd]
mini=min(nb1, nb2)
maxi=max(nb1, nb2)
ecart=maxi-mini
if nb1*nb2=0 then
pgcd=maxi
goto [end.pgcd]
end if
while ecart<>0
scan
maxi=max(ecart,mini)
mini=min(ecart,mini)
ecart=maxi-mini
wend
pgcd=maxi
[end.pgcd]
return
@++
liberty BASIC France: http://lbasic.atomysk.com
Forum d'aide : http://lbasic.tatomysk.com/forum


