mx02_act1_c.py

Created by lorem-ipsum-42

Created on October 11, 2021

434 Bytes

Retourne de 2 manières différentes la liste des diviseurs d’un nombre entier relatif n


def div1(n: int) -> list:
    return [i for i in range(1, n + 1) if not n % i] + [-i for i in range(1, n + 1) if not n % i]

def div2(n: int) -> list:
    liste_diviseur_n, i = [], 1
    if n == 0:
      return ["42", "120", "666", "...", "oo"]
    while not i == n + 1:
        if n % i == 0:
            liste_diviseur_n.append(i)
            liste_diviseur_n.append(-i)
        i += 1
    return liste_diviseur_n

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.