Dashboard Temp Share Shortlinks Frames API

HTMLify

Day 100
Views: 4 | Author: djdj
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
class Solution {
    /**
     * @param Integer[] $nums
     * @return Integer
     */
    function findGCD($nums) {
        $min = min($nums);
        $max = max($nums);
        return $this->gcd($min, $max);
    }

    function gcd($a, $b) {
        while ($b != 0) {
            $temp = $b;
            $b = $a % $b;
            $a = $temp;
        }
        return $a;
    }
}