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-10 of 19 results. Next

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

A002963 Number of chisel strokes required for Roman numerals for n.

Original entry on oeis.org

1, 2, 3, 3, 2, 3, 4, 5, 3, 2, 3, 4, 5, 5, 4, 5, 6, 7, 5, 4, 5, 6, 7, 7, 6, 7, 8, 9, 7, 6, 7, 8, 9, 9, 8, 9, 10, 11, 9, 4, 5, 6, 7, 7, 6, 7, 8, 9, 7, 2, 3, 4, 5, 5, 4, 5, 6, 7, 5, 4, 5, 6, 7, 7, 6, 7, 8, 9, 7, 6, 7, 8, 9, 9, 8, 9, 10, 11, 9, 8, 9, 10, 11, 11, 10, 11, 12, 13, 11, 4, 5, 6, 7, 7, 6, 7, 8, 9, 7, 2, 3, 4
Offset: 1

Views

Author

Keywords

Comments

Chisel strokes for numerals: I,1; V,2; X,2; L,2; C ( = < ),2; D,3; M,4.
For more about Roman numerals, see A006968.
a(A002964(n)) = n. - Reinhard Zumkeller, Apr 14 2013

Crossrefs

Programs

  • Haskell
    a002963 = ch 0 . a061493 where
         ch s 0 = s
         ch s x = ch (s + [0,1,2,2,2,2,3,4] !! d') x'
                  where  (x',d) = divMod x 10; d' = fromInteger d
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Maple
    with(StringTools): A002963 := proc(n) local r: r:=convert(n, roman): return add(parse(SubstituteAll( SubstituteAll( SubstituteAll( SubstituteAll( SubstituteAll( SubstituteAll( SubstituteAll(r[j], "I", "1"), "V", "2"), "X", "2"), "L", "2"), "C", "2"), "D", "3"), "M", "4")), j=1..length(r)): end: seq(A002963(n), n=1..102); # Nathaniel Johnston, May 18 2011
  • Mathematica
    a[n_] := Characters[ IntegerString[n, "Roman"]] /. {"I" -> 1, "V" -> 2, "X" -> 2, "L" -> 2, "C" -> 2, "D" -> 3, "M" -> 4} // Total; Table[a[n], {n, 1, 102}] (* Jean-François Alcover, Sep 10 2013 *)
  • PARI
    {A002963(n, c=[1000, 4, 900, 6, 500, 3, 400, 5, 100, 2, 90, 4, 50, 2, 40, 4, 10, 2, 9, 3, 5, 2, 4, 3, 1, 1], s=0)= forstep(i=1, #c, 2, while(n>=c[i], n-=c[i]; s+=c[i+1])); s} \\ M. F. Hasler, Jul 27 2016
    
  • Python
    a002963 = lambda n: sum((d+1-(d==2))*(i%5)+(d+2-(d==1))*(i>4) if (i+1)%5 else 3+d+(d==2)*(i==9) for d,i in enumerate(map(int,str(n)[::-1])))
    # Nicholas Stefan Georgescu, Feb 27 2023

Extensions

More terms from David W. Wilson
Data double-checked by M. F. Hasler, Jul 27 2016

A003587 Roman numerals with 1 letter, in numerical order; then those with 2 letters, etc.

Original entry on oeis.org

1, 5, 10, 50, 100, 500, 1000, 2, 4, 6, 9, 11, 15, 20, 40, 51, 55, 60, 90, 101, 105, 110, 150, 200, 400, 501, 505, 510, 550, 600, 900, 1001, 1005, 1010, 1050, 1100, 1500, 2000, 3, 7, 12, 14, 16, 19, 21, 25, 30, 41, 45, 52, 54, 56, 59, 61, 65, 70, 91, 95, 102, 104, 106, 109, 111, 115, 120, 140, 151
Offset: 1

Views

Author

N. J. A. Sloane, J. H. Conway and John Jackson (ab158(AT)freenet.uchsc.edu)

Keywords

Comments

The sequence is finite because 3999 is the largest number that can be written using the symbols I,V,X,L,C,D,M. - J. Lowell, Nov 17 2020
The Romans had symbols for 5000, 10000, 50000, and 100000, but they have no simple equivalents in our current alphabet. See The Book of Numbers, p. 19. The symbol for 100000 is sometimes represented by (((|))). - N. J. A. Sloane, Nov 28 2020

Examples

			Written in Roman numerals, the sequence reads: I, V, X, L, C, D, M, II, IV, VI, IX, XI, XV, XX, XL, LI, LV, LX, XC, CI, CV, CX, CL, CC, CD, DI, DV, DX, DL, DC, CM, MI, MV, MX, MV, MC, MD, MM, III, VII, XII, ... - _M. F. Hasler_, Jan 12 2015
		

References

  • J. H. Conway and R. K. Guy, The Book of Numbers, Copernicus Press, NY, 1996, p. 19.

Crossrefs

Programs

  • Mathematica
    A003587full = SortBy[Range[3999], StringLength[RomanNumeral[#]] &];
    A003587full[[;;100]] (* Paolo Xausa, Mar 19 2024 *)
  • PARI
    for(d=1,4,for(n=d,d*1000,A006968(n)==d && print1(n","))) \\ M. F. Hasler, Jan 12 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 roman(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 sorted(list(range(1, 4000)), key=lambda x: (len(roman(x)), x))
    print(afull()) # Michael S. Branicky, Dec 04 2022

Extensions

More terms from M. F. Hasler, Jan 12 2015

A036746 Numbers with "long" representations in Roman notation: given by last n letters from ...MMMDCCCLXXXVIII.

Original entry on oeis.org

1, 2, 3, 8, 18, 28, 38, 88, 188, 288, 388, 888, 1888, 2888, 3888
Offset: 1

Views

Author

Keywords

Comments

Also: Least number using n symbols when written as Roman numeral, cf. A006968 and A061493. One could prefix a conventional a(0)=0. - M. F. Hasler, Jan 12 2015

Crossrefs

Programs

  • Haskell
    import Data.List (inits, elemIndex)
    import Data.Maybe (mapMaybe)
    a036746 n = a036746_list !! (n-1)
    a036746_list = map (+ 1) $ mapMaybe (`elemIndex` a061493_list)
       (map (read . reverse) $ tail $ inits $ reverse $ show $ a061493 3888)
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Mathematica
    (* assign the 3999 Roman numerals to the variable 'lst' so that lst = {I, II, III, ... MMMCMXCVII, MMMCMXCVIII, MMMCMXCIX}, e.g. using the link to Schildberger's file, then *) f[1] = 1; f[n_] := Block[{k = 2}, While[ StringLength@ SymbolName@ lst[[k]] != n, k++ ]; k]; Array[f, 15] (* Checked by Robert G. Wilson v, Aug 13 2008; edited by M. F. Hasler, Jan 12 2015 *)
  • PARI
    A036746(n)=(n%4+8/9)\.1^(n\4) \\ M. F. Hasler, Jan 12 2015

Formula

a(n) = min{ k>0 | A006968(k)=n }. - M. F. Hasler, Jan 12 2015

Extensions

Checked by Robert G. Wilson v, Aug 13 2008
Edited by M. F. Hasler, Jan 12 2015

A078715 Palindromic Roman numerals.

Original entry on oeis.org

1, 2, 3, 5, 10, 19, 20, 30, 50, 100, 190, 200, 300, 500, 1000, 1900, 2000, 3000
Offset: 1

Views

Author

Rick L. Shepherd, Dec 19 2002

Keywords

Comments

This sequence is consistent with the Roman numerals as expressed in the Schildberger link. 4 (usually IV now) could be included in a variant of this sequence as IIII is sometimes used (especially on clock faces). To make this or similar sequences well-defined for numbers larger than 3999, it must be decided whether and how to handle the apostrophus (backward-C), the vinculum (bar), the frame, or even other multiplier notations used at various times in representations of larger Roman numerals. Recalling the "Y2K crisis", will there be a(n even milder) "Y4M crisis"? In particular, is 4000 to be represented as MMMM, (I)(I)(I)(I) (where parentheses are used to represent C and the apostrophus), MV (with vinculum over the V), IV (with vinculum over both I and V) or IIII with vinculum over all four I's? If there is no general agreement, could Roman civilization be at risk (once again)?
Indices of terms in A061493 which are also in A002113. - M. F. Hasler, Jan 12 2015

Examples

			I, II, III, V, X, XIX, XX, XXX, L, C, CXC, CC, CCC, D, M, MCM, MM, MMM
		

References

  • Encyclopaedia Britannica, 1981 ed., Vol. 11, "Mathematics, History of", p. 647.
  • Webster's Third New International Dictionary (Unabridged), 1976 ed., "Cardinal Numbers Table" and footnotes, p. 1549.

Crossrefs

Cf. A061493, A006968 (Roman numerals main entry), A002113 (Palindromic Arabic numerals).
Subsequence of A093703.

Programs

  • Haskell
    a078715 n = a078715_list !! (n-1)
    a078715_list = filter ((== 1) . a136522 . a061493) [1..3999]
    -- Reinhard Zumkeller, Apr 14 2013
    
  • Mathematica
    Select[Range[3000], PalindromeQ[RomanNumeral[#]] &] (* Paolo Xausa, Mar 03 2024 *)
  • PARI
    is_A078715(n)=Vecrev(n=Str(A061493(n)))==Vec(n) \\ M. F. Hasler, Jan 12 2015

Formula

A136522(A061493(a(n))) = 1. - Reinhard Zumkeller, Apr 14 2013

A036787 Length of Roman notation for n = length of decimal representation.

Original entry on oeis.org

1, 5, 11, 15, 20, 40, 51, 55, 60, 90, 102, 104, 106, 109, 111, 115, 120, 140, 151, 155, 160, 190, 201, 205, 210, 250, 300, 401, 405, 410, 450, 502, 504, 506, 509, 511, 515, 520, 540, 551, 555, 560, 590, 601, 605, 610, 650, 700, 901, 905, 910, 950, 1003, 1007
Offset: 1

Views

Author

Keywords

Examples

			15 = XV has length 2 in both notations.
		

Crossrefs

Programs

  • Haskell
    a036787 n = a036787_list !! (n-1)
    a036787_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[1100],StringLength[IntegerString[#,"Roman"]] == IntegerLength[ #]&] (* Harvey P. Dale, Jul 25 2011 *)
  • PARI
    is_A036787(n)=#Str(n)==#Str(A061493(n)) \\ M. F. Hasler, Jan 12 2015

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

A057226 Number of different symbols needed to express n as a Roman numeral.

Original entry on oeis.org

1, 1, 1, 2, 1, 2, 2, 2, 2, 1, 2, 2, 2, 3, 2, 3, 3, 3, 2, 1, 2, 2, 2, 3, 2, 3, 3, 3, 2, 1, 2, 2, 2, 3, 2, 3, 3, 3, 2, 2, 3, 3, 3, 4, 3, 4, 4, 4, 3, 1, 2, 2, 2, 3, 2, 3, 3, 3, 3, 2, 3, 3, 3, 4, 3, 4, 4, 4, 3, 2, 3, 3, 3, 4, 3, 4, 4, 4, 3, 2, 3, 3, 3, 4, 3, 4, 4, 4, 3, 2, 3, 3, 3, 4, 3, 4, 4, 4, 3, 1, 2, 2, 2, 3, 2
Offset: 1

Views

Author

Helge T. Blohmer (crusher(AT)k-town.de), Sep 19 2000

Keywords

Comments

Sequence created using classic Roman numerals, i.e., 99 = XCIX, not the questionable IC.

Examples

			a(97) = 4 as you need I, V, X and C to express XCVII.
		

Crossrefs

Programs

  • Haskell
    a057226 = a043537 . a061493  -- Reinhard Zumkeller, Apr 14 2013
  • Maple
    with(StringTools): A057226 := proc(n) local r: r:=convert(n, roman): return `if`(Search("I",r)>0,1,0) + `if`(Search("V",r)>0,1,0) + `if`(Search("X",r)>0,1,0) + `if`(Search("L",r)>0,1,0) + `if`(Search("C",r)>0,1,0) + `if`(Search("D",r)>0,1,0) + `if`(Search("M",r)>0,1,0): end: seq(A057226(n), n=1..105); # Nathaniel Johnston, May 18 2011
  • Mathematica
    Table[Length[Union[Characters[IntegerString[n,"Roman"]]]],{n,110}] (* Harvey P. Dale, Mar 18 2013 *)

Formula

a(n) = A043537(A061493(n)). - Reinhard Zumkeller, Apr 14 2013

A093783 Sum of digits of n in Roman numeral representation.

Original entry on oeis.org

1, 2, 3, 6, 5, 6, 7, 8, 11, 10, 11, 12, 13, 16, 15, 16, 17, 18, 21, 20, 21, 22, 23, 26, 25, 26, 27, 28, 31, 30, 31, 32, 33, 36, 35, 36, 37, 38, 41, 60, 61, 62, 63, 66, 65, 66, 67, 68, 71, 50, 51, 52, 53, 56, 55, 56, 57, 58, 61, 60, 61, 62, 63, 66, 65, 66, 67, 68
Offset: 1

Views

Author

Reinhard Zumkeller, May 17 2004

Keywords

Examples

			n=42 == XLII: a(42) = 'X' + 'L' + 'I' + 'I' = 10+50+1+1 = 62.
		

Crossrefs

Programs

  • Haskell
    a093783 n = q 0 $ a061493 n where
         q s 0 = s
         q s x = q (s + [0,1,5,10,50,100,500,1000] !! d') x'
                 where  (x',d) = divMod x 10; d' = fromInteger d
    -- Reinhard Zumkeller, Apr 14 2013
    (HP 49G calculator)
    ::
      CK1&Dispatch
      # FF
      ::
        FPTR2 ^DupQIsZero?
        caseSIZEERR
        FPTR2 ^Z>S
        Z0_
        SWAP
        DUPLEN$
        ZERO_DO
        DUP
        ISTOP-INDEX
        SUB$1#
        BINT48
        #-
        BINT4
        OVER#=
        OVER
        BINT9
        #=
        OR
        IT
        #2+
        FPTR2 ^#>Z
        Z10_
        INDEX@
        FPTR2 ^RP#
        FPTR2 ^RMULText
        ROT
        FPTR2 ^RADDext
        SWAPLOOP
        DROP
      ;
    ;
    Gerald Hillier, Sep 08 2015
  • Maple
    A093783 := proc(n) local r: r:=convert(n, roman): return add(convert(r[j], arabic), j=1..length(r)): end: seq(A093783(n), n=1..68); # Nathaniel Johnston, May 18 2011
  • Mathematica
    Total[#2 FromRomanNumeral[#1] & @@@ Tally[Characters@ RomanNumeral@ #]] & /@ Range@ 68 (* Michael De Vlieger, Sep 08 2015, Version 10.2 *)

A199921 Number of Roman numerals < 4000 with n letters.

Original entry on oeis.org

7, 31, 93, 215, 389, 573, 691, 691, 573, 389, 215, 93, 31, 7, 1
Offset: 1

Views

Author

Martin Renner, Nov 12 2011

Keywords

Comments

Note that the sequence is completely symmetrical with the addition of the single (notional) Roman string of length zero. - Ian Duff, Jun 27 2017

Examples

			a(1) = 7, since there are the seven one-letter roman numerals I, V, X, L, C, D, M.
a(15) = 1, since there is one fifteen-letter roman numeral MMMDCCCLXXXVIII.
		

Crossrefs

Programs

  • Haskell
    import Data.List (group, sort)
    a199921 n = a199921_list !! (n-1)
    a199921_list = map length $ group $ sort $ map (a055642 . a061493) [1..3999]
    -- Reinhard Zumkeller, Apr 14 2013
  • Maple
    for i from 1 to 15 do L[i]:={}: od: for n from 1 to 3999 do L[length(convert(n,roman))]:={op(L[length(convert(n,roman))]),n}; od:
    seq(nops(L[i]),i=1..15); # Martin Renner, Nov 13 2011
  • Mathematica
    romanLetterCount = Table[0, {15}]; j = 1; While[j < 4000, romanLetterCount[[StringLength[IntegerString[j, "Roman"]]]]++; j++]; romanLetterCount (* Alonso del Arte, Nov 12 2011 *)
    Rest[BinCounts[StringLength[RomanNumeral[Range[3999]]]]] (* Paolo Xausa, Mar 19 2024 *)

A003588 Roman numerals with 1 letter, in alphabetical order; then those with 2 letters, etc.

Original entry on oeis.org

100, 500, 1, 50, 1000, 5, 10, 200, 400, 101, 150, 900, 105, 110, 600, 501, 550, 505, 510, 2, 4, 9, 51, 55, 60, 1100, 1500, 1001, 1050, 2000, 1005, 1010, 6, 90, 11, 40, 15, 20, 300, 201, 250, 205, 210, 401, 450, 405, 410, 102, 104, 109, 151, 155, 160, 901, 950, 905, 910, 106
Offset: 1

Views

Author

N. J. A. Sloane, J. H. Conway and John Jackson (ab158(AT)freenet.uchsc.edu)

Keywords

Comments

In this sequence Roman numerals are limited to k <= 3999. - Sean A. Irvine, Dec 04 2022

Crossrefs

Programs

  • Mathematica
    A003588full = FromRomanNumeral[SortBy[RomanNumeral[Range[3999]], StringLength]];
    A003588full[[;;100]] (* Paolo Xausa, Mar 19 2024 *)
  • PARI
    (Roman(n,s=Vecsmall("IVXLCDM"))=Strchr(apply(c->s[c-48], Vec(Vecsmall(Str(A061493(n))))))); vecsort(vector(4000,n,[#t=Roman(n),t]),,1)[1..100] \\ M. F. Hasler, Jan 12 2015

Extensions

Corrected, edited and extended by M. F. Hasler, Jan 12 2015
Showing 1-10 of 19 results. Next