Sum

in #ita14 hours ago

declare(strict_types=1);

function sumOfMultiples(int $number, array $multiples): int{

$res = 1;

$setres = [];

 foreach($multiples as $mult){

        if($mult < 1 || $mult > $number) continue;

        $i = 1;

            while ($res = ($i \* $mult) < $number){

                $res = $i \* $mult;

                $setres[] = $res;

                $i++;

        }

}

$set = array\_unique($setres);

return array\_sum($set);

}