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

A061493 Roman numerals written using 1 for I, 2 for V, 3 for X, 4 for L, 5 for C, 6 for D, 7 for M.

Original entry on oeis.org

1, 11, 111, 12, 2, 21, 211, 2111, 13, 3, 31, 311, 3111, 312, 32, 321, 3211, 32111, 313, 33, 331, 3311, 33111, 3312, 332, 3321, 33211, 332111, 3313, 333, 3331, 33311, 333111, 33312, 3332, 33321, 333211, 3332111, 33313, 34, 341, 3411, 34111, 3412
Offset: 1

Views

Author

Frank Ellermann, Jun 12 2001

Keywords

Comments

From Daniel Forgues, Jan 16 2015: (Start)
The Romans in the era of the Roman Empire did not have 0 as a number.
The initial "N" (nulla, meaning "none", or nihil, meaning "nothing") was used as a zero symbol in a table of Roman numerals by Bede or his colleague around 725, but even in the Middle Ages it never became a standard. (End) [Corrected by M. F. Hasler and Peter Luschny, Aug 16 2025]
3999 (MMMCMXCIX) is the largest decimal number that has a well-defined Roman numeral representation. Therefore the sequence deliberately stops there to avoid the ambiguous representations of larger numbers. - Jamie Robert Creasey, May 01 2021
The use of 'N' to indicate 0 or "none" long survived in the historic apothecaries' system of measurement, well into the 20th century, to designate quantities in pharmaceutical prescriptions. - M. F. Hasler, Aug 16 2025

Examples

			a(14) = 312 because 14 = XIV in Roman, and I,V,X are coded as 1,2,3 respectively.
a(66) = 4321, LXVI is 50+10+5+1 = 66, a(44) = 3412, XLIV is -10+50-1+5 = 44
		

Crossrefs

Programs

  • Haskell
    a061493 n = read $ r 1 [] n :: Integer where
      r _ roms 0 = roms
      r p roms z = case p of
        1 -> r 2 (d '1' '2' '3' m) z'
        2 -> r 3 (d '3' '4' '5' m ++ roms) z'
        3 -> r 4 (d '5' '6' '7' m ++ roms) z'
        4 -> replicate z '7' ++ roms
        where (z',m) = divMod z 10
      d i j k c =
        [[],[i],[i,i],[i,i,i],[i,j],[j],[j,i],[j,i,i],[j,i,i,i],[i,k]] !! c
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Mathematica
    Array[FromDigits[Characters@ RomanNumeral[#] /. {"I" -> 1, "V" -> 2, "X" -> 3, "L" -> 4, "C" -> 5, "D" -> 6, "M" -> 7}] &, 44] (* Michael De Vlieger, May 01 2021 *)
  • PARI
    {A061493(n,s="",c=[1000,7,900,57,500,6,400,56,100,5,90,35,50,4,40,34,10,3,9,13,5,2,4,12,1,1])= forstep(i=1,#c,2,while(n>=c[i],n-=c[i];s=Str(s,c[i+1])));eval(s)} \\ 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 int("7"*m + f("567", c) + f("345", x) + f("123", i))
    print([a(n) for n in range(1, 45)]) # Michael S. Branicky, Aug 24 2022
    
  • Python
    import roman
    def A061493(n, d={ord(c):str(i) for i,c in enumerate("NIVXLCDM")}):
        return int(roman.toRoman(n).translate(d)) # M. F. Hasler, Aug 16 2025

Formula

a(n)=i <=> A003587(i)=n, for i in {1,...,7}, i.e., A061493 is a left inverse of A003587 on {1,...,7}. - M. F. Hasler, Jan 12 2015

Extensions

0 removed again by Georg Fischer, Jan 20 2019

A036788 Length of Roman notation for n <= length of decimal representation.

Original entry on oeis.org

1, 5, 10, 11, 15, 20, 40, 50, 51, 55, 60, 90, 100, 101, 102, 104, 105, 106, 109, 110, 111, 115, 120, 140, 150, 151, 155, 160, 190, 200, 201, 205, 210, 250, 300, 400, 401, 405, 410, 450, 500, 501, 502, 504, 505, 506, 509, 510, 511, 515, 520, 540, 550, 551, 555
Offset: 1

Views

Author

Keywords

Comments

The Roman numeration system used here is the naive one taught in primary school. This sequence, like many others involving numeration systems, is neither well-defined nor interesting for large values of n. - N. J. A. Sloane, Jul 03 2008

Examples

			15 = XV has length 2 in both notations.
		

Crossrefs

Programs

  • Haskell
    a036788 n = a036788_list !! (n-1)
    a036788_list = [x | x <- [1..], a006968 x <= a055642 x]
    -- Reinhard Zumkeller, Apr 20 2013
  • Maple
    for n from 1 to 3999 do if(length(convert(n, roman)) <= length(n))then printf("%d, ", n): fi: od: # Nathaniel Johnston, May 18 2011
  • Mathematica
    Select[Range[560],StringLength[IntegerString[#,"Roman"]]<= IntegerLength[ #]&] (* Harvey P. Dale, Dec 18 2011 *)

Formula

A006968(a(n)) <= A055642(a(n)). - Reinhard Zumkeller, Apr 20 2013

Extensions

Corrected and extended by Larry Reeves (larryr(AT)acm.org), Sep 25 2000

A036786 Length of Roman notation for n < length of decimal representation.

Original entry on oeis.org

10, 50, 100, 101, 105, 110, 150, 200, 400, 500, 501, 505, 510, 550, 600, 900, 1000, 1001, 1002, 1004, 1005, 1006, 1009, 1010, 1011, 1015, 1020, 1040, 1050, 1051, 1055, 1060, 1090, 1100, 1101, 1105, 1110, 1150, 1200, 1400, 1500, 1501, 1505, 1510, 1550
Offset: 1

Views

Author

Keywords

Examples

			1000 = M is shorter in Roman numerals, so 1000 is in this sequence.
		

Crossrefs

Programs

  • Haskell
    a036786 n = a036786_list !! (n-1)
    a036786_list = [x | x <- [1..], a006968 x < a055642 x]
    -- Reinhard Zumkeller, Apr 20 2013
  • Maple
    for n from 1 to 3999 do if(length(convert(n,roman)) < length(n))then printf("%d, ",n): fi: od: # Nathaniel Johnston, May 18 2011
  • Mathematica
    Select[Range[2000],StringLength[IntegerString[#,"Roman"]]Harvey P. Dale, Feb 10 2015 *)

Formula

A006968(a(n)) < A055642(a(n)). - Reinhard Zumkeller, Apr 20 2013

Extensions

Corrected by Larry Reeves (larryr(AT)acm.org), Sep 25 2000

A093788 The Roman numerals, with "i" replaced by "1", "v" replaced by "5", "x" replaced by 10, etc.

Original entry on oeis.org

1, 11, 111, 15, 5, 51, 511, 5111, 110, 10, 101, 1011, 10111, 1015, 105, 1051, 10511, 105111, 10110, 1010, 10101, 101011, 1010111, 101015, 10105, 101051, 1010511, 10105111, 1010110, 101010, 1010101, 10101011, 101010111, 10101015, 1010105
Offset: 1

Views

Author

William J. Rapaport (rapaport(AT)buffalo.edu), May 17 2004

Keywords

Comments

A more compact and easier to parse version is A061493, where I, V, X, L, ... are replaced by 1, 2, 3, 4, ... The terms of this sequence can be converted to those of A061493 by changing digits '5' to '2' and deleting each digit '0' upon increasing by 2 the nonzero digit to its left. - M. F. Hasler, Jul 25 2016

Crossrefs

Programs

  • PARI
    {A093788(n)=A061493(n,,[1000, 1000, 900, 1001000, 500, 500, 400, 100500, 100, 100, 90, 10100, 50, 50, 40, 1050, 10, 10, 9, 110, 5, 5, 4, 15, 1, 1])} \\ M. F. Hasler, Jul 25 2016

Extensions

Cross-references added and data double-checked by M. F. Hasler, Jul 25 2016
Showing 1-5 of 5 results.