Suppose we have a list of positive numbers called nums, we have to find the largest positive number that divides each of the number.
So, if the input is like [14,28,70,56], then the output will be 14.
To solve this, we will follow these steps −
Let us see the following implementation to get better understanding −
import math class Solution: def solve(self, nums): ans = nums for x in nums: ans = math.gcd(ans, x) return ans ob = Solution() print(ob.solve([14,28,70,56]))