Geometric Series

    0

    0

    HARIGOVIND VALSAKUMAR

    PythonGeometricSeries
    HGV Public Cookbook

    Function to series to return geometric series

    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
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Explore
    • Cookbooks
    • Playground
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.