Array.from()
to create an array of the desired length, lim/n
. Use a map function to fill it with the desired values in the given range.const arithmeticProgression = (n, lim) =>
Array.from({ length: Math.ceil(lim / n) }, (_, i) => (i + 1) * n );
arithmeticProgression(5, 25); // [5, 10, 15, 20, 25]
Subscribe to get resources directly to your inbox. You won't receive any spam! ✌️