divmx.py

Created by remi-aerts04

Created on October 09, 2021

306 Bytes

Indique la liste des diviseurs entiers naturels de n par une boucle for (div1(n)) et par une boucle while (div2(n)).


def div1(n):
  if n==0:
    return "Tout nombre est diviseur de 0"
  l=[]
  for i in range(1, n+1):
    if n%i==0:
      l.append(i)
  return l
  
def div2(n):
  if n==0:
    return "Tout nombre est diviseur de 0"
  i=1
  l=[]
  while i<=n:
    if n%i==0:
      l.append(i)
    i+=1
  return l

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.