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.

Showing 1-5 of 5 results.

A006968 Number of letters in Roman numeral representation of n.

Original entry on oeis.org

1, 2, 3, 2, 1, 2, 3, 4, 2, 1, 2, 3, 4, 3, 2, 3, 4, 5, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 3, 4, 5, 6, 5, 4, 5, 6, 7, 5, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 1, 2, 3, 4, 3, 2, 3, 4, 5, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 3, 4, 5, 6, 5, 4, 5, 6, 7, 5, 4, 5, 6, 7, 6, 5, 6, 7, 8, 6, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 1, 2, 3, 4, 3, 2
Offset: 1

Views

Author

Keywords

Comments

How is this sequence defined for large values? - Charles R Greathouse IV, Feb 01 2011
See A078715 for a discussion on the Roman 4M-problem. - Reinhard Zumkeller, Apr 14 2013
The sequence can be considered to be defined via the formula (as A055642 o A061493), so the question is to be posed in A061493, not here. - M. F. Hasler, Jan 12 2015

References

  • GCHQ, The GCHQ Puzzle Book, Penguin, 2016. See page 60.
  • Netnews group rec.puzzles, Frequently Asked Questions (FAQ) file. (Science Section).
  • N. J. A. Sloane and Simon Plouffe, The Encyclopedia of Integer Sequences, Academic Press, 1995 (includes this sequence).

Crossrefs

Programs

  • Haskell
    a006968 = lenRom 3 where
       lenRom 0 z = z
       lenRom p z = [0, 1, 2, 3, 2, 1, 2, 3, 4, 2] !! m + lenRom (p - 1) z'
                    where (z',m) = divMod z 10
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Maple
    A006968 := proc(n) return length(convert(n,roman)): end: seq(A006968(n),n=1..105); # Nathaniel Johnston, May 18 2011
  • Mathematica
    a[n_] := StringLength[ IntegerString[ n, "Roman"]]; Table[a[n], {n, 1, 105}] (* Jean-François Alcover, Dec 27 2011 *)
  • PARI
    A006968(n)=#Str(A061493(n)) \\ M. F. Hasler, Jan 11 2015
    
  • Python
    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 a(n):
        m, c, x, i = n//1000, (n%1000)//100, (n%100)//10, n%10
        return len("M"*m + f("CDM", c) + f("XLC", x) + f("IVX", i))
    print([a(n) for n in range(1, 101)]) # Michael S. Branicky, Mar 03 2024
    
  • Python
    import roman
    def A006968(n): return len(roman.toRoman(n)) # M. F. Hasler, Aug 18 2025
  • R
    nchar(paste(as.roman(1 :1024))) # N. J. A. Sloane, Aug 23 2009, corrected by M. F. Hasler, Aug 18 2025
    

Formula

A006968 = A055642 o A061493, i.e., a(n) = A055642(A061493(n)). - M. F. Hasler, Jan 11 2015

Extensions

More terms from Eric W. Weisstein

A341737 a(n) is the number of segments necessary to represent n in the Cistercian numeral system.

Original entry on oeis.org

1, 2, 2, 2, 2, 3, 2, 3, 3, 4, 2, 2, 3, 3, 3, 3, 3, 3, 4, 4, 2, 3, 2, 3, 3, 4, 3, 4, 3, 4, 2, 3, 3, 3, 3, 4, 3, 4, 4, 5, 2, 3, 3, 3, 3, 4, 3, 4, 4, 5, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 2, 3, 3, 3, 3, 4, 3, 4, 4, 5, 3, 3, 4, 4, 4, 4, 4, 4, 5, 5, 3, 4, 3, 4, 4, 5, 4
Offset: 0

Views

Author

Stefano Spezia, Feb 18 2021

Keywords

Comments

The sequence is finite because the numeral system of Cistercian monks allows us to represent the numbers from 0 to 9999.

Crossrefs

Programs

  • Mathematica
    SN:={"0"->1,"1"->2,"2"->2,"3"->2,"4"->2,"5"->3,"6"->2,"7"->3,"8"->3,"9"->4}; OI:={11,15,17,19,22,28,29,51,55,57,59,71,75,77,79,82,88,89,91,92,95,97,98,99}; Table[(Characters[IntegerString[Floor[n/100]]]/. SN//Total)-Length[Characters[IntegerString[Floor[n/100]]]]+1-If[MemberQ[OI,Floor[n/100]],1,0]-Boole[Floor[n/100]==99]+(Characters[IntegerString[Mod[n,100]]]/. SN//Total)-Length[Characters[IntegerString[Mod[n,100]]]]+1-If[MemberQ[OI,Mod[n,100]],1,0]-Boole[Mod[n,100]==99]-1,{n,0,9999}]
    (* Function for visualizing a Cistercian numeral *)
    CistercianNumeral[n_]:=ResourceFunction["CistercianNumberEncode"][n];

Formula

a(n) <= 9.

A092197 Brevity advantage of "new style" over "old style" Roman numerals.

Original entry on oeis.org

0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 2, 2, 2, 2, 4, 2, 2, 2, 2, 5, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 0, 0, 0, 0, 2, 0, 0, 0, 0, 3, 3, 3, 3, 3, 5, 3, 3, 3, 3, 6, 0, 0, 0, 0, 2, 0
Offset: 1

Views

Author

Marc LeBrun, Feb 24 2004

Keywords

Examples

			a(4)=2 because old style takes four letters (IIII) versus new style's two (IV).
		

Crossrefs

Programs

  • Maple
    A092197 := proc(n) return length(convert(n, roman, period=early)) - length(convert(n, roman)): end: seq(A092197(n),n=1..105); # Nathaniel Johnston, May 18 2011

Formula

a(n) = A092196(n) - A006968(n).

A118121 Roman numeral complexity of n.

Original entry on oeis.org

1, 2, 3, 2, 1, 2, 3, 4, 2, 1, 2, 3, 4, 3, 2, 3, 4, 4, 3, 2, 3, 4, 5, 4, 3, 4, 5, 5, 4, 3, 4, 5, 5, 5, 4, 4, 5, 5, 5, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 1, 2, 3, 4, 3, 2, 3, 4, 5, 3, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 3, 4, 5, 6, 5, 4, 5, 5, 6, 5, 4, 4, 5, 6, 5, 5, 6, 6, 6, 6, 2, 3, 4, 5, 4, 3, 4, 5, 6, 4, 1, 2, 3
Offset: 1

Views

Author

Jonathan Vos Post, May 12 2006

Keywords

Comments

The least number of letters {I, V, X, L, C, D, M} needed to represent n by an expression with conventional Roman numerals, addition, multiplication and parentheses. a(n) <= A006968(n) and a(n) <= A005245(n). Conventional Roman numerals are very efficient at reducing complexity from number of letters in "old style" Roman numerals (A092196) and more primitive representations. In all but two examples shown (38, 88) the use of {+,*} reduces the representation by a single symbol (counting + and *); in these two it saves 2 symbols. In an alternate history, complexity theory and minimum description length could have been invented by Gregorius Catin.

Examples

			a(n) < A006968(n) for these examples. Here "<" means less in letter count:
a(18) = 4 [IX + IX < XVIII]; a(28) = 5 [XIV * II < XXVIII]; a(33) = 5 [XI * III < XXXIII]; a(36) = 4 [VI * VI < XXXVI]; a(37) = 5 [VI * VI + I < XXXVII]; a(38) = 5 [XIX * II < XXXVIII]; a(77) = 5 [XI * VII < LXXVII]; a(78) = 6 [XIII * VI < LXXVIII]; a(81) = 4 [IX * IX < LXXXI]; a(82) = 5 [XLI * II < LXXXII]; a(83) = 6 [XLI * II + I < LXXXIII]; a(84) = 5 [XX * IV < LXXXIV]; a(87) = 6 [IX * IX + VI < LXXXVII]; a(88) = 6 [XI * VIII < LXXXVIII].
		

Crossrefs

A119281 Number of counting rods to represent n in the ancient Chinese rod numeral system.

Original entry on oeis.org

0, 1, 2, 3, 4, 5, 2, 3, 4, 5, 1, 2, 3, 4, 5, 6, 3, 4, 5, 6, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 7, 8, 9, 10, 2, 3, 4, 5, 6, 7, 4, 5, 6, 7, 3, 4, 5, 6, 7, 8, 5, 6, 7, 8, 4, 5, 6, 7, 8, 9, 6, 7, 8, 9, 5, 6, 7, 8, 9, 10, 7, 8, 9, 10, 1, 2, 3
Offset: 0

Views

Author

Rick L. Shepherd, May 12 2006

Keywords

Comments

Contrast with A092196, the number of letters to represent n in ancient Roman numerals. Negative numbers were represented by the same number of rods but usually of a different color (usually black rods with red rods for positive numbers). It's unclear to me whether 0 itself was ever formally considered represented by the absence of all counting rods, but it does seem reasonable that a(0)=0 from the example below.

Examples

			a(105) = 6 because 105 was represented on a counting board by placing one counting rod in the compartment for hundreds, no rods where those representing tens were normally placed and five rods in the units compartment.
		

Crossrefs

Programs

  • PARI
    a(n)= tmp=abs(n); r=0; l=length(Str(tmp)); for(k=1,l, d=tmp-(tmp\10)*10; tmp=tmp\10; if(d<6, r=r+d, r=r+d-4)); r

Formula

a(n) = a(-n) = A007953(n) - 4*A102677(n) = A092196(n) + 4*(number of 5s in n).
Showing 1-5 of 5 results.