Skip to content
Onsite

Restarting Counter Pattern

EasyP3Coding

A counter runs from 1 up to i for each i from 1 to n, restarting at 1 every time. Return all the values it shows, one entry per value, in order. For n = 3 the answer is [1, 1, 2, 1, 2, 3].

Example 1

Input
n = 3
Output
[1,1,2,1,2,3]

Example 2

Input
n = 1
Output
[1]

Example 3

Input
n = 2
Output
[1,1,2]

Constraints

  • 1 <= n <= 100

Hints

Run checks the 3 visible tests, Submit all 8.