<?php
echo "Informe o primeiro número natural: \n";
$n1 = (int) trim(fgets(STDIN));
echo "Informe o segundo número natural: \n";
$n2 = (int) trim(fgets(STDIN));

$a = $n1;
$b = $n2;
$divisor = 2;
$mmc_acumulador = 1;

do {
    if ($a % $divisor == 0 or $b % $divisor == 0) {
        if ($a % $divisor == 0) {
            $a = $a / $divisor;
        }
        if ($b % $divisor == 0) {
            $b = $b / $divisor;
        }
        $mmc_acumulador *= $divisor;
        echo "Divisor: $divisor | A: $a | B: $b | MMC Parcial: $mmc_acumulador\n";
    } else {
        $divisor++;
    }
} while ($a > 1 or $b > 1);

echo "O M.M.C é: {$mmc_acumulador}\n";
?>

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: