<?php
fscanf(STDIN, "%d %d", $M, $N);

$acumuladorM = $M;
$acumuladorN = $N;

// calcula $M fatorial
if ($M == 0 || $M == 1) {
    $acumuladorM = 1;
} else {
    for ($i = $M; $i > 1; $i--) {
        $acumuladorM *= ($i - 1);
    }
}


// calcula $N fatorial
if ($N == 0 || $N == 1) {
    $acumuladorN = 1;
} else {
    for ($i = $N; $i > 1; $i--) {
        $acumuladorN *= ($i - 1);
    }
}


echo $acumuladorM + $acumuladorN."\n";
?>

Embed on website

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