Series from For loop (is there a repository for Integer Sequences?)

B/c they’re different functions w/ different names w/ diff. implementation:

  1. seqIntsRepeatedNTimesEach()
  2. periodicIntSeqRepeatedNTimes()

1st 1 repeats each number from a range (lo, hi) n times.
For example, seqIntsRepeatedNTimesEach(2, 3, 5) would output:
3 3 4 4 5 5, which is 3 twice, 4 twice and 5 twice.

2nd 1 repeats a whole range (lo, hi) n times.
For example, periodicIntSeqRepeatedNTimes(2, 3, 5) would output:
3 4 5 3 4 5, which is the sequence 3, 4, 5 repeated twice.

Notice though that when we have 1st param (n = 1), both functions output the same result.

Param (n = 0) would output an empty array for both functions.

And negative param n is sanitized to positive n via abs().

2 Likes