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);
      
      Typescript language logo

      Geometric Progression

      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.

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.