I am trying to write a function that accepts list as an argument to my gcd
function. Would something like this work?
def find_my_gcd(a_list):
def gcd (x,y):
while y!=0:
x,y=y,x%y
return x
Now,how do I make my gcd
function step through a list,i.e a_list=[12,24,18,6]
, iterate through gcd(12,24)
, gcd(12,18)
,gcd(12,6)
and returns a single value.