Given an array of integers, return the smallest common factors of all integers in the array.

When i say **Smallest Common Factor** i mean the smallest number above 1 that can divide all numbers in the array without a remainder.

If there are no common factors above 1, return 1 (technically 1 is always a common factor).

Source: codewars | Difficulty: EASY
Tags: Mathematics

Starter code: def scf(lst):
	

Solutions:
def scf(lst):
	return next((k for k in range(2, 1 + min(lst, default=1)) if all((n % k == 0 for n in lst))), 1)


from functools import reduce
from math import floor, gcd, sqrt

def smallest_factor(n):
	return next((d for d in range(2, floor(sqrt(n)) + 1) if n % d == 0), n)

def scf(nums):
	return 1 if nums == [] else smallest_factor(reduce(gcd, nums))


def scf(arr):
	factors_list = []
	dict = {}
	min_list = []
	for element in arr:
		for factor in range(1, element + 1):
			if element % factor == 0:
				factors_list.append(factor)
	for factor in factors_list:
		if factor in dict and factor != 1:
			dict[factor] += 1
		else:
			dict[factor] = 1
	for factor in factors_list:
		if dict[factor] == len(arr):
			min_list.append(factor)
	if min_list != []:
		return min_list[0]
	else:
		return 1


def scf(arr):
	print(arr)
	if arr == []:
		return 1
	ret = []
	for j in arr:
		for i in range(1, int(j ** 0.5) + 1):
			if j % i == 0:
				ret.append(i)
				ret.append(j // i)
	if len(ret) == len(arr) * 2:
		return 1
	print(ret)
	ret1 = []
	for k in set(ret):
		if ret.count(k) >= len(arr) and k != 1:
			ret1.append(k)
	if ret1 == []:
		return 1
	else:
		return min(ret1)


def scf(arr):
	return next((i for i in range(2, min(arr, default=1) + 1) if all((x % i == 0 for x in arr))), 1)


def scf(arr):
	(div, all_div, diz) = ([], [], {})
	for x in arr:
		for i in range(2, x + 1):
			if not x % i:
				div.append(i)
		diz[x] = div
		all_div.extend(div)
		div = []
	all_div = sorted(set(all_div))
	return next((x for x in all_div if all((x in diz[it] for it in diz))), 1)


def scf(arr):
	return next((i for i in range(2, min(arr) + 1) if all((v % i == 0 for v in arr))), 1) if arr else 1


from math import gcd, sqrt
from functools import reduce

def scf(xs):
	try:
		d = reduce(gcd, xs)
	except TypeError:
		return 1
	else:
		return next((i for i in range(2, int(sqrt(d)) + 1) if d % i == 0), d)