sec_algo_boucles_tp2.py

Created by morelo-lolo

Created on February 28, 2020

287 Bytes

TP2 : Somme des entiers consécutifs au carré : une formule 1) Utiliser un programme python pour déterminer la somme des 100 premier nombres entiers au carré. Puis vérifier la formule de l’image ci-contre. 2) Combien de carré successifs doit-on additionner au minimum pour que leur somme soit supérieur à 10^9 ?


def somme_carre(n):
  # n est le nombre d'éléments à additionner
  Somme=0
  for k in range(1,n+1):
    Somme=Somme+k**2
  return Somme
  
def somme_carre_limite(seuil):
  Somme=0
  n=0
  while Somme<seuil:
    Somme=Somme+n**2
    n=n+1
  return n-1
  
  

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.