suitegeometrique.py

Created by hicham-choukour

Created on December 12, 2023

1.15 KB


def suite_geometrique(U0,q,n): 
    # génère les n+1 premiers termes de la suite arithmétique de raison r et de terme initial u0 
  
    # on initialise la variable ui et la liste u avec le terme initial de la suite 
    ui = U0; u = [U0]; S=U0; 
     
    # parcours des indices des termes de la suite : 1 -> n 
    for i in range(1,n+1): 
        ui *= q # ajout de r au terme précédent pour obtenir le terme d'indice i 
        S+=ui
        print("U",i,"=",ui)
        if (i==n) :
          print("La somme des ", n+1," premiers terme est")
          print("est S=",S)

        u.append(ui) # ajout du terme obtenu à la liste 
    # renvoie la liste des n+1 premiers termes de la suite arithmétique 
    return u
   
   
U0=float(input("Saisir la valeur de U0="))
q=float(input("Saisir la valeur de r="))
print(" ")
print("Un=q^n*U0")
print(" ")
print("Un+1=q*Un")
print(" ")

print("Un=Uk*q^(n-k)")
print(" ")

print("1+q+q2+...+q^n=(1-q^(n+1))/(1-q)")
print(" ")

print("S=U0+U1+U2+U3+...+Un")
print("S=(1-q^(n+1))/(1-q))")
print(" ")
n=float(input("Saisir la valeur de n="))
# Type your text here
print("U 0=",U0)
suite_geometrique(U0,q,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.