Ana,
To receive two values, one must either consider N as a list of integers, or receive two arguments in the function signature, such as:
def divisores(num1, num2):
Although your procedure works, note the following:
You test the division of all numbers between 0 - number received, even if the smallest possible division (2) happens in num / 2;
You again test every numpy array if the rest of the division is 0;
Although not a very charming algorithm, one way you perform fewer iterations is as follows:
div_1 = set() #Cria um set vazio
for i in range(1, int(num1/2+1)): #itera de 1 até metade do valor numérico
if num1%i == 0: #testa se mod é zero.
div_1.add(i) #anexa o valor de i ao set de divisores do primeiro numero
Note that this function, like its code, does not return the value itself as a possible divisor (in this case, when you enter 30, the values obtained will be: {1, 2, 3, 5, 6, 10 , 15) (30 excluded). In addition, you can consider using the "set" object instead of lists, since the numbers should not be repeated.
In case, if the final function were to just find the intersection of the common division values, you could include everything in the same loop, as it is not, a simplistic approach is to run another iteration in to identify the same divisors of the other number ( num2).
For the intersection, you could accomplish the following:
lista_divisores_comuns = div_1.intersection(div_2)
The final code would look like:
def divisores(num1, num2):
div_1 = set()
div_2 = set()
for i in range(1, int(num1/2+1)):
if num1%i == 0:
div_1.add(i)
for i in range(1, int(num2/2+1)):
if num2%i == 0:
div_2.add(i)
lista_divisores_comuns = div_1.intersection(div_2)
return div_1, div_2, lista_divisores_comuns