Answers for "les diviseurs d'un nombre python"

1

les diviseurs d'un nombre python

# This function returns a list containing all the factors of a ginven parameters n
def getFactors(n):
    # Create an empty list for factors
    factors=[];

    # Loop over all factors
    for i in range(1, n + 1):
        if n % i == 0:
            factors.append(i)

    # Return the list of factors
    return factors

# Call the function with a given value
print (getFactors(256))
Posted by: Guest on March-10-2021
1

les diviseurs d'un nombre python

#obtenir tous les diviseurs d'un nombre 'n'
divisor = [d for d in range(1,n+1) if n%d==0]
Posted by: Guest on March-10-2021

Code answers related to "les diviseurs d'un nombre python"

Python Answers by Framework

Browse Popular Code Answers by Language