funzione ricorsiva mcm (c++)
Inviato: dom gen 25, 2009 4:10 pm
mi potreste dire la definizione della funzione ricorsiva del minimo comune multiplo?...
mcm(a,b) * MCD(a,b) = a * b
function MCD(a, b)
while a ≠ b
if a > b
a := a - b
else
b := b - a
end while
return a
function MCD(a, b)
if b = 0
return a;
else
return MCD(b, a % b); <- Qui con a % b intendo a MOD b, che in C++, ecc. si scrive appunto tramite l'operatore %
}