Geometric Progression

    0

    0

    Giovanny Gongora

    Codiga's TypeScript Recipes

    Initializes an array containing the numbers in the specified range where start and end are inclusive and the ratio between two terms is step. Returns an error if step equals 1.

    const geometricProgression = (end: number, start: number = 1, step: number = 2) =>
      Array.from({
        length: Math.floor(Math.log(end / start) / Math.log(step)) + 1,
      }).map((_, i) => start * step ** i);
    
    Codiga Logo
    Codiga Hub
    • Rulesets
    • Playground
    • Snippets
    • Cookbooks
    Legal
    • Security
    • Privacy Policy
    • Code Privacy
    • Terms of Service
    soc-2 icon

    We are SOC-2 Compliance Certified

    G2 high performer medal

    Codiga – All rights reserved 2022.