Massimo comun divisore e minimo comune multiplo

Un programma in fortran 90 per la determinazione del massimo comun divisore e minimo comune multiplo di una serie di numeri interi

!**********************************************
!* Geatest common divisor and Smallest common *
!* multiple of several integer numbers *
!* —————————————— *
!* Ref.: “Mathematiques en Turbo-Pascal *
!* By M. Ducamp and A. Reverchon (2), *
!* Eyrolles, Paris, 1988″ [BIBLI 05]. *
!* —————————————— *
!* Sample run: *
!* *
!* GCD and SCM of integer numbers: *
!* *
!* First number: 9936 *
!* Next number : 414 *
!* Next number : 3174 *
!* Next number : 0 *
!* *
!* GCD = 138. *
!* SCM = 228528. *
!* *
!* F90 version by J-P Moreau *
!**********************************************
program Test_gcd
print *,’ ‘
print *,’GCD and SCM of integer numbers:’
print *,’ ‘
write(*,100,advance=’no’); read *, pg
pp=pg
10 write(*,110,advance=’no’); read *, x
xx=x
if (x>0.) then
pg=GCD(pg,xx)
xx=x
pp=pp*xx/GCD(pp,xx)
end if
if(abs(x)1e10.or.b>1e10) then
GCD=1; return
endif
if (a.eq.0.or.b.eq.0) then
GCD=1; return
endif
if (a

PUBBLICITÀ
PUBBLICITÀ
Le vostre opinioni
Pubblicato il mercoledì 16 gennaio 2008 in: Programmi

Ultimi interventi

Vedi tutti

Link correlati

Inserisci per primo un commento a questo articolo.

PUBBLICITÀ
PUBBLICITÀ
L'email è richiesta ma non verrà mostrata ai visitatori.
Commenta questo articolo

Registrati per riservare il tuo nickname preferito e per caricare il tuo avatar. Se sei già registrato, effettua il login per usare il tuo nickname.

Si No

Anteprima del commento