Look-and-say sequence: roman numerals edition Challenge description

We've had a few challenges involving the Look-and-say sequence. Quick reminder:


The sequence starts with 1,
Subsequent terms of this sequence are generated by enumerating each group of repeating digits in the previous term,


So the first few terms are:

1        "one"
11       "one one" (we look at the previous term)
21       "two ones"
1211     "one two, one one"
111221   "one one, one two, two ones"
312211   "three ones, two twos, one one"


Now let's do the same thing, but use Roman Numerals instead. We start with I and follow the same rules (we apply the digit-counting rule to characters instead, so we read IVX as one one, one five, one ten instead of one four, one ten or some other way):

I           "one"
II          "one one"
III         "two ones" = "II" + "I"
IIII        "three ones" = "III" + "I"
IVI         "four ones" = "IV" + "I"
IIIVII      "one one, one five, one one"
IIIIIVIII   "three ones, one five, two ones" = ("III" + "I") + ("I" + "V") + ("II" + "I")


Given a positive integer N, either:


Output first N numerals of this sequence (any reasonable separator is fine, as well as ["I", "II", "III", ...]
Output Nth term of this sequence (it may be 0-indexed).


Remember to make your code as short as possible, since this is a code-golf challenge!

EDIT: I believe that there is always one standard/preferred way of expressing integers as roman numerals, (like 95 -> XCV instead of VC). Couple of Roman numeral converters I found online corroborate my opinion. If in doubt, use an online converter, as listing all the possible edge-cases and specific rules of writing Roman numerals is not the point of this challenge.

EDIT2: @PeterTaylor and @GregMartin pointed out that only numbers less or equal to 5 appear in the sequence, so you don't have to worry about the ambiguity of Roman numerals (numbers 1 - 8 are I, II, III, IV, V, VI, VII, and VIII)
Perl, 49 bytes

Includes +1 for -p

Run with the 0-based index on STDIN, e.g.

ecce.pl &lt;&lt;&lt; 14


ecce.pl:

#!/usr/bin/perl -p
s,(.)\1*,$&amp;/$1%182 .$1,eg for($_=/$/)x$`;y;19;IV


Magic formulas are so magic.

Normally I would use ($_=//)x$' to make the loop control one byte shorter, but scoring on this site gives that a handicap of 2 so it ends up 1 byte longer. On older perls you can drop the space before for. Some versions of perl force you to add a final ; to close the transliteration. But what is given above is the code that works on my system.

Explanation

Working backwards from solution to code:

The string transformations we need:

I     -&gt; II
II    -&gt; III
III   -&gt; IIII
IIII  -&gt; IVI
IIIII -&gt; VI

V     -&gt; IV
VV    -&gt; IIV


Each replacement ends with the repeated character. I will get a sequence of the same characters using regex /(.)\1*/, so this can be done by appending $1. The part before the -&gt; is in $&amp;. With that I still need:

I     -&gt; I
II    -&gt; II
III   -&gt; III
IIII  -&gt; IV
IIIII -&gt; V

V     -&gt; I
VV    -&gt; II


Write I as 1 and V as 9:

1     -&gt; 1
11    -&gt; 11
111   -&gt; 111
1111  -&gt; 19
11111 -&gt; 9

9     -&gt; 1
99    -&gt; 11


By dividing the part before -&gt; by the repeated digit this becomes:

1     -&gt; 1
11    -&gt; 11
111   -&gt; 111
1111  -&gt; 19
11111 -&gt; 9

1     -&gt; 1
11    -&gt; 11


So now the original repeated V is not an exception anymore. So I want an expression that makes this happen:

1     -&gt; 1
11    -&gt; 11
111   -&gt; 111
1111  -&gt; 19
11111 -&gt; 9


And this can be done by a simple modulo 182:

1     % 182 = 1
11    % 182 = 11
111   % 182 = 111
1111  % 182 = 19
11111 % 182 = 9


(this even gets IIIIII to VI right though it isn't needed here)

All that is left is initializing the working variable to 1 for index 0, repeat this transformation in a loop and at the end replace 1 by I and 9 by V

1, 9 and 182 is the only parameter combination for which this simple formula works.