def geometric_series(nth_term, start_term_a, common_ratio_r):
          if "" in (nth_term, start_term_a, common_ratio_r):
              return ""
          series = []
          power = 1
          multiple = common_ratio_r
          for _ in range(int(nth_term)):
              if series == []:
                  series.append(start_term_a)
              else:
                  power += 1
                  series.append(str(float(start_term_a) * float(multiple)))
                  multiple = pow(float(common_ratio_r), power)
          return series
      
      Python language logo

      Geometric Series

      Python
      GeometricSeries
      HGV Public Cookbook

      Function to series to return geometric series

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.