dm2_premiere_2020.py

Created by frederic-junier

Created on October 06, 2019

533 Bytes


def existe(s, p):
  """Détermine s'il existe u et v
  tels que s = u + v et p = u * v"""
  delta = s ** 2 - 4 * p
  if delta >= 0:
    return True
  else:
    return False
    
def existe2(s, p):
  """Détermine s'il existe u et v
  tels que s = u + v et p = u * v
  Version plus élégante"""
  return s ** 2 - 4 * p >= 0


def seuil(s):
  """Retourne lee rang du plus petit 
  nombre triangulaire >= s"""
  n = 0
  while n * (n+1) / 2 < s:
    n = n + 1
  return n
  
print(existe(9,2))
print(seuil(1000))

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.