login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Run lengths of digits when concatenating Roman numerals less than 4000, cf. A093796.
2

%I #20 Mar 04 2024 04:31:07

%S 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,

%T 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,

%U 3,1,3,3,1,2,1,1,1,1,1,1,2,1,1,3,1,1

%N Run lengths of digits when concatenating Roman numerals less than 4000, cf. A093796.

%C See A078715 for a discussion on the Roman 4M-problem;

%C a(n) <= 7, that is, the longest run of consecutive equal digits in A093796 has length = 7; see also example.

%H Reinhard Zumkeller, <a href="/A222581/b222581.txt">Table of n, a(n) for n = 1..19770</a>

%H Eric Weisstein's World of Mathematics, <a href="http://mathworld.wolfram.com/RomanNumerals.html">Roman Numerals</a>

%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Roman_numerals">Roman numerals</a>

%e 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;

%e 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;

%e 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;

%e a(30)=5, there is just one run with length 5: "XXXXX" which is contained in the concatenation of XIX, XX and XXI;

%e 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.

%t A222581full = Map[Length, Split[Flatten[FromRomanNumeral[Characters[RomanNumeral[ Range[3999]]]]]]]; A222581full[[;;100]] (* _Paolo Xausa_, Mar 03 2024 *)

%o (Haskell)

%o import Data.List (group)

%o a222581 n = a222581_list !! (n-1)

%o a222581_list = map length $ group a093796_list

%o (Python)

%o from itertools import groupby

%o def f(s, k):

%o return s[:2] if k==4 else (s[1]*(k>=5)+s[0]*(k%5) if k<9 else s[0]+s[2])

%o def r(n):

%o m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10

%o return "M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i)

%o def afull():

%o return [len(list(g)) for k, g in groupby("".join(r(i) for i in range(1, 4000)))]

%o print(afull()[:90]) # _Michael S. Branicky_, Mar 03 2024

%Y Cf. A006968.

%K nonn,base,fini,full

%O 1,1

%A _Reinhard Zumkeller_, Apr 14 2013