Arithmetic Progression

const arithmeticProgression  = (n, lim) =>
  Array.from({ length: Math.ceil(lim / n) }, (_, i) => (i + 1) * n );


arithmeticProgression(5, 25); // [5, 10, 15, 20, 25]

Here's the snippet for Arithmetic Progression in JavaScript.

BETA Snippet explanation automatically generated by OpenAI:

Here is what the above code is doing:
1. Create an object literal with a length property equal to the ceiling of the limit divided by the step.
2. Use Array.from to create an array with the number of entries equal to the length property.
3. Use a for loop to iterate over the array and multiply

Snippet By Dhairya Shah

·

Created February 27th, 2022

·

Report Snippet