A222581 Run lengths of digits when concatenating Roman numerals less than 4000, cf. A093796.
7, 3, 1, 1, 2, 1, 4, 3, 1, 1, 2, 1, 3, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1, 5, 1, 2, 2, 2, 3, 2, 1, 1, 2, 1, 2, 1, 1, 2, 1, 2, 2, 1, 3, 2, 1, 7, 1, 3, 2, 3, 3, 3, 1, 1, 3, 1, 3, 1, 1, 3, 1, 2, 3, 1, 3, 3, 1, 2, 1, 1, 1, 1, 1, 1, 2, 1, 1, 3, 1, 1
Offset: 1
Examples
The 3999 Roman numerals of all numbers less than 4000 consist of 30000 digits; there are 19770 runs of consecutive equal digits: a(19770) = 1 is the last term of this sequence; a(1)=a(52)=7, there are two runs with length 7: the first is "IIIIIII" which is the prefix of the concatenation of I, II, III and IV, the second is "XXXXXXX" which is contained in the concatenation of XXIX, XXX and XXXI; a(1022)=a(14573)=6, there are also two runs with length 6: the first is "CCCCCC" which is a prefix of the concatenation of CCC and CCCI, the second is "MMMMMM" which is a prefix of the concatenation of MMM and MMMI; a(30)=5, there is just one run with length 5: "XXXXX" which is contained in the concatenation of XIX, XX and XXI; a(7)=a(644)=a(1359)=a(9375)=a(19194)=4, there are five runs with length 4: "IIII", two times "CCCC" and "MMMM", they occur in concatenations of (VIII, IX), (CC, CCI), (CCCXC, CCCXCI), (MM, MMI), (MMMCM, MMMCMI), respectively.
Links
- Reinhard Zumkeller, Table of n, a(n) for n = 1..19770
- Eric Weisstein's World of Mathematics, Roman Numerals
- Wikipedia, Roman numerals
Crossrefs
Cf. A006968.
Programs
-
Haskell
import Data.List (group) a222581 n = a222581_list !! (n-1) a222581_list = map length $ group a093796_list
-
Mathematica
A222581full = Map[Length, Split[Flatten[FromRomanNumeral[Characters[RomanNumeral[ Range[3999]]]]]]]; A222581full[[;;100]] (* Paolo Xausa, Mar 03 2024 *)
-
Python
from itertools import groupby def f(s, k): return s[:2] if k==4 else (s[1]*(k>=5)+s[0]*(k%5) if k<9 else s[0]+s[2]) def r(n): m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10 return "M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i) def afull(): return [len(list(g)) for k, g in groupby("".join(r(i) for i in range(1, 4000)))] print(afull()[:90]) # Michael S. Branicky, Mar 03 2024
Comments