cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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

This page as a plain text file.
%I A222581 #21 Feb 16 2025 08:33:19
%S A222581 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 A222581 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 A222581 3,1,3,3,1,2,1,1,1,1,1,1,2,1,1,3,1,1
%N A222581 Run lengths of digits when concatenating Roman numerals less than 4000, cf. A093796.
%C A222581 See A078715 for a discussion on the Roman 4M-problem;
%C A222581 a(n) <= 7, that is, the longest run of consecutive equal digits in A093796 has length = 7; see also example.
%H A222581 Reinhard Zumkeller, <a href="/A222581/b222581.txt">Table of n, a(n) for n = 1..19770</a>
%H A222581 Eric Weisstein's World of Mathematics, <a href="https://mathworld.wolfram.com/RomanNumerals.html">Roman Numerals</a>
%H A222581 Wikipedia, <a href="http://en.wikipedia.org/wiki/Roman_numerals">Roman numerals</a>
%e A222581 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 A222581 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 A222581 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 A222581 a(30)=5, there is just one run with length 5: "XXXXX" which is contained in the concatenation of XIX, XX and XXI;
%e A222581 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 A222581 A222581full = Map[Length, Split[Flatten[FromRomanNumeral[Characters[RomanNumeral[ Range[3999]]]]]]]; A222581full[[;;100]] (* _Paolo Xausa_, Mar 03 2024 *)
%o A222581 (Haskell)
%o A222581 import Data.List (group)
%o A222581 a222581 n = a222581_list !! (n-1)
%o A222581 a222581_list = map length $ group a093796_list
%o A222581 (Python)
%o A222581 from itertools import groupby
%o A222581 def f(s, k):
%o A222581     return s[:2] if k==4 else (s[1]*(k>=5)+s[0]*(k%5) if k<9 else s[0]+s[2])
%o A222581 def r(n):
%o A222581     m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10
%o A222581     return "M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i)
%o A222581 def afull():
%o A222581     return [len(list(g)) for k, g in groupby("".join(r(i) for i in range(1, 4000)))]
%o A222581 print(afull()[:90]) # _Michael S. Branicky_, Mar 03 2024
%Y A222581 Cf. A006968.
%K A222581 nonn,base,fini,full
%O A222581 1,1
%A A222581 _Reinhard Zumkeller_, Apr 14 2013